From 186692d0992bc6cefcc157846a6f7b64dcc40b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 15 Jun 2009 15:03:19 +0000 Subject: Add some upstream completion patches + new completion files for procstat, sockstat and fstat. Submitted by: Baptiste Daroussin --- shells/zsh/Makefile | 16 ++++ shells/zsh/files/_fstat | 15 ++++ shells/zsh/files/_procstat | 17 ++++ shells/zsh/files/_sockstat | 23 ++++++ .../zsh/files/patch-Completion-Unix-Command-_mount | 92 +++++++++++++++------- .../files/patch-Completion-Unix-Type-_file_systems | 18 +++-- .../files/patch-Completion-Unix-Type-_zfs_dataset | 27 +++++++ 7 files changed, 171 insertions(+), 37 deletions(-) create mode 100644 shells/zsh/files/_fstat create mode 100644 shells/zsh/files/_procstat create mode 100644 shells/zsh/files/_sockstat create mode 100644 shells/zsh/files/patch-Completion-Unix-Type-_zfs_dataset (limited to 'shells') diff --git a/shells/zsh/Makefile b/shells/zsh/Makefile index 8f115418834d..f8c811f357c5 100644 --- a/shells/zsh/Makefile +++ b/shells/zsh/Makefile @@ -7,6 +7,7 @@ PORTNAME= zsh PORTVERSION= 4.3.10 +PORTREVISION= 1 CATEGORIES= shells MASTER_SITES= SF .if !defined(NOPORTDOCS) @@ -32,6 +33,8 @@ CONFIGURE_ARGS= --with-term-lib="ncursesw ncurses" --with-tcsetpgrp \ --enable-function-subdirs EXTRA_PATCHES= ${FILESDIR}/extra-patch-bsdtar +EXTRA_COMPLETION_FILES= _fstat _procstat _sockstat +EXTRA_COMPLETION_DIR= Completion/BSD/Command OPTIONS= ZSH_GDBM "Enable GDBM support (GPL)" off \ ZSH_MEM "Enable zsh-mem and zsh-secure-free options" on \ @@ -99,6 +102,19 @@ post-patch: ${WRKSRC}/Src/Modules/*.mdd @${SED} -i "" -e "s,/etc/,${LOCALBASE}/etc/," \ ${WRKSRC}/Functions/MIME/zsh-mime-setup +.ifdef EXTRA_COMPLETION_FILES + @echo "===> Installing extra completion files" +.for COMPFILE in ${EXTRA_COMPLETION_FILES} + @(if [ -f ${WRKSRC}/${EXTRA_COMPLETION_DIR}/${COMPFILE} ] ; then \ + echo "${EXTRA_COMPLETION_DIR}/${COMPFILE} already exists" ; \ + exit 1 ; \ + else \ + echo ${EXTRA_COMPLETION_DIR}/${COMPFILE} ; \ + ${CP} ${FILESDIR}/${COMPFILE} \ + ${WRKSRC}/${EXTRA_COMPLETION_DIR}/${COMPFILE} ; \ + fi) +.endfor +.endif @${FIND} ${WRKSRC}/Completion -type f -iname '*.orig' -delete post-build: diff --git a/shells/zsh/files/_fstat b/shells/zsh/files/_fstat new file mode 100644 index 000000000000..553d07313c68 --- /dev/null +++ b/shells/zsh/files/_fstat @@ -0,0 +1,15 @@ +#compdef fstat + +local pids +pids=(${${${(f)"$(/usr/bin/procstat -ah)"}/[[:space:]]#/}/[[:space:]]*[[:space:]](ELF32[[:space:]]|-[[:space:]]#)/:}) + +_arguments -s \ +'-f[Restrict examination to files open in the same file systems as the named file arguments]' \ +'-M[Extract values associated with the name list from the specified core]:core:_files' \ +'-N[Extract the name list from the specified system]:system:' \ +'-m[Include memory-mapped files in the listing]' \ +'-n[Numerical format]' \ +'-p[Report all files open by the specified process]:Process id:(($pids))' \ +'-u[Report all files open by the specified user]:User:_users' \ +'-v[Verbose mode]' \ +'*:Files:_files' diff --git a/shells/zsh/files/_procstat b/shells/zsh/files/_procstat new file mode 100644 index 000000000000..476daa8212f9 --- /dev/null +++ b/shells/zsh/files/_procstat @@ -0,0 +1,17 @@ +#compdef procstat + +local pids +#get list of pids and associated process name as comment +pids=(${${${(f)"$(/usr/bin/procstat -ah)"}/[[:space:]]#/}/[[:space:]]*[[:space:]](ELF32[[:space:]]|-[[:space:]]#)/:}) + +_arguments -s \ +'-b[Display binary information for the process]' \ +'-c[Display command line arguments for the process]' \ +'-f[Display file descriptor information for the process]' \ +'-k[Display the stacks of kernel threads in the process]' \ +'-s[Display security credential information for the process]' \ +'-t[Display thread information for the process]' \ +'-v[Display virtual memory mappings for the process]' \ +'-h[Suppress table headers.]' \ +'-a[All processes]' \ +':Process id:(($pids))' diff --git a/shells/zsh/files/_sockstat b/shells/zsh/files/_sockstat new file mode 100644 index 000000000000..2acbe6bec351 --- /dev/null +++ b/shells/zsh/files/_sockstat @@ -0,0 +1,23 @@ +#compdef sockstat + +local tmp_proto protocols proto + +tmp_proto=(${${(M)${(f)"$(udevordir' ) ;; @@ -78,28 +75,63 @@ args=( '(*)-a[unmount all mounted file systems]' '-A[unmount all mounted file systems except the root]' -@@ -819,7 +822,7 @@ +@@ -819,7 +825,28 @@ devordir) fi case "$OSTYPE" in - *freebsd*|dragonfly*) -+ freebsd*|dragonfly*) ++ dragonfly*) ++ while read mline; do ++ case $mline[(w)1] in ++ \#* ) ++ ;; ++ proc) ++ ;; ++ *) ++ [[ $mline[(w)3] == swap ]] || \ ++ dev_tmp+=( $mline[(w)1] ) \ ++ mp_tmp+=( $mline[(w)2] ) ++ ;; ++ esac ++ done < /etc/fstab ++ ++ _alternative \ ++ 'hosts:host:_hosts -S :' \ ++ 'devices:device:compadd -a dev_tmp' \ ++ 'directories:mount point:compadd -a mp_tmp' && ret=0 ++ ;; ++ freebsd*) ++ local _glabel while read mline; do case $mline[(w)1] in \#* ) -@@ -861,8 +864,13 @@ +@@ -833,6 +860,16 @@ devordir) + ;; + esac + done < /etc/fstab ++ # ++ /sbin/ggatel list | while read mline; do ++ dev_tmp+=(/dev/$mline) ++ done ++ ++ # add glabel devices ++ _glabel=(${(M)${(f)"$(/sbin/glabel list)"}:#*Name:[[:space:]]*/*}) ++ for mline ($_glabel);do ++ dev_tmp+=( mline[(w)3] ) ++ done + + _alternative \ + 'hosts:host:_hosts -S :' \ +@@ -859,6 +896,12 @@ udevordir) + dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) + mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) ;; ++ freebsd*|dragonfly*) ++ /sbin/mount | while read mline; do ++ dev_tmp+=( $mline[(w)1] ) ++ mp_tmp+=( $mline[(w)3] ) ++ done ++ ;; *) /sbin/mount | while read mline; do -- mp_tmp+=( $mline[(w)1] ) -- dev_tmp+=( $mline[(w)3] ) -+ if [[ "$OSTYPE" =~ .*freebsd.* ]]; then -+ dev_tmp+=( $mline[(w)1] ) -+ mp_tmp+=( $mline[(w)3] ) -+ else -+ mp_tmp+=( $mline[(w)1] ) -+ dev_tmp+=( $mline[(w)3] ) -+ fi - done - ;; - esac + mp_tmp+=( $mline[(w)1] ) diff --git a/shells/zsh/files/patch-Completion-Unix-Type-_file_systems b/shells/zsh/files/patch-Completion-Unix-Type-_file_systems index 9061e6c7084a..99171b9bdc75 100644 --- a/shells/zsh/files/patch-Completion-Unix-Type-_file_systems +++ b/shells/zsh/files/patch-Completion-Unix-Type-_file_systems @@ -1,15 +1,19 @@ ---- Completion/Unix/Type/_file_systems.orig 2007-09-27 14:00:03.000000000 +0200 -+++ Completion/Unix/Type/_file_systems 2008-10-29 15:20:52.099580070 +0100 -@@ -16,7 +16,11 @@ +--- Completion/Unix/Type/_file_systems ++++ Completion/Unix/Type/_file_systems +@@ -16,10 +16,15 @@ case $OSTYPE in ;; osf*) fss=( advfs ufs nfs mfs cdfs ) ;; solaris*) fss=( ufs nfs hsfs s5fs pcfs cachefs tmpfs ) ;; - freebsd*|dragonfly*) -+ freebsd*) -+ fss=( cd9660 devfs ext2fs fdesc kernfs linprocfs mfs msdosfs nfs -+ ntfs nullfs nwfs portal procfs smbfs std udf ufs umap unionfs ) -+ ;; + dragonfly*) fss=( cd9660 devfs ext2fs fdesc kernfs linprocfs mfs msdos nfs ntfs null nwfs portal procfs std udf ufs umap union ) ;; ++ freebsd*) ++ fss=( cd9660 devfs ext2fs fdesc kernfs linprocfs mfs msdosfs nfs ++ ntfs nullfs nwfs portal procfs smbfs std udf ufs umap unionfs ++ reiserfs xfs) ++ ;; + darwin*) + fss=( afp cd9660 cddafs devfs fdesc hfs lfs msdos nfs + ntfs smbfs synthfs udf ufs volfs webdav ) diff --git a/shells/zsh/files/patch-Completion-Unix-Type-_zfs_dataset b/shells/zsh/files/patch-Completion-Unix-Type-_zfs_dataset new file mode 100644 index 000000000000..4b59be90f50c --- /dev/null +++ b/shells/zsh/files/patch-Completion-Unix-Type-_zfs_dataset @@ -0,0 +1,27 @@ +--- ./Completion/Unix/Type/_zfs_dataset.orig 2009-06-09 10:49:20.305960368 +0000 ++++ ./Completion/Unix/Type/_zfs_dataset 2009-06-09 10:50:24.299466247 +0000 +@@ -9,7 +9,23 @@ + [[ -n $type[(r)snap] ]] && typearg=( $typearg snapshot ) + [[ -n $typearg ]] && typearg=( -t ${(j:,:)typearg} ) + +-datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} ) ++case "$OSTYPE" in ++ freebsd*) ++ local -i osreldate ++ osreldate=${${(f)"$(/sbin/sysctl kern.osreldate)"}[(w)2]} ++ if (( $osreldate >= 702102 ));then ++ datasetlist=( ${="$(zfs list -H -o name ${typearg:--t all})":#no datasets available} ) ++ else ++ datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} ) ++ fi ++ ;; ++ netbsd*) ++ datasetlist=( ${="$(zfs list -H -o name ${typearg:--t all})":#no datasets available} ) ++ ;; ++ *) ++ datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} ) ++ ;; ++esac + + expl_type=${typearg[2,-1]//,/\/} + if [[ -n $type[(r)mtpt] ]]; then -- cgit v1.2.3