about summary refs log tree commit diff
path: root/Completion/Unix/Command/_fuser
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_fuser')
-rw-r--r--Completion/Unix/Command/_fuser94
1 files changed, 54 insertions, 40 deletions
diff --git a/Completion/Unix/Command/_fuser b/Completion/Unix/Command/_fuser
index ba0f301ea..f497729fc 100644
--- a/Completion/Unix/Command/_fuser
+++ b/Completion/Unix/Command/_fuser
@@ -1,10 +1,18 @@
 #compdef fuser
 
-local -a args arg1
+local -a args argf variant
 typeset -A opt_args
 
-if _pick_variant -c $words[1] psmisc='(#i)psmisc' unix -V; then
+args=(
+  '-u[append the user name of the process owner to each PID]'
+  '(-f)-c[list all processes accessing files on the filesystem specified by name]'
+  '(-c)-f[list all processes accessing named files]'
+)
+argf=( '*:file:_files' )
 
+_pick_variant -r variant psmisc='(#i)psmisc' $OSTYPE -V
+case $variant in
+  psmisc)
   (( $+functions[_fuser_services] )) ||
   _fuser_services() {
     local expl suf ret=1
@@ -23,45 +31,51 @@ if _pick_variant -c $words[1] psmisc='(#i)psmisc' unix -V; then
       compset -S ',*' || suf=( -S ${${opt_args[-n]/?*/,}:-/} -r "/, \t\n\-" )
       _ports $suf && ret=0
     fi
-      
+
     return ret
   }
 
-  _arguments \
-    '(-s)-a[show all files specified on the command line]' \
-    {-c,-m}'[list all processes accessing files on the filesystem specified by name]' \
-    '-k[kill processes accessing the file]' \
-    '-i[ask for confirmation before killing]' \
-    '-l[list all known signal names]' \
-    '-n[select name space]:namespace:(file udp tcp)' \
-    '(-a)-s[silent operation]' \
-    '-signal[send alternate signal with -k]:signal:_signals' \
-    '-u[append the user name of the process owner to each PID]' \
-    '-v[verbose mode]' \
-    '-V[display version information]' \
-    '-4[search only for IPv4 sockets]' \
-    '-6[search only for IPv6 sockets]' \
-    '*:name: _alternative "files:file:_files" "services:service:_fuser_services"'
-
-else
-  case $OSTYPE in
-    solaris2.9 )
-      args=(
-	'-n[list only processes with non-blocking mandatory locks]' 
-	'-s[send alternate signal with -k]:signal:_signals' 
-      )
-    ;;
-    sysv4 )
-      (( $+words[(r)-k] )) && arg1=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' )
-    ;;
-  esac
+    args+=(
+      '(-s)-a[show all files specified on the command line]' \
+      {-c,-m}'[list all processes accessing files on the filesystem specified by name]' \
+      '-k[kill processes accessing the file]' \
+      '-i[ask for confirmation before killing]' \
+      '(-)-l[list all known signal names]' \
+      '-n[select name space]:namespace:(file udp tcp)' \
+      '(-a -u -v)-s[silent operation]' \
+      '-v[verbose mode]' \
+      '-V[display version information]' \
+      '-4[search only for IPv4 sockets]' \
+      '-6[search only for IPv6 sockets]' \
+    )
+    argf=( '*:name: _alternative "files:file:_files" "services:service:_fuser_services"' )
+    [[ -prefix -  && -z ${${words[1,CURRENT-1]}[(r)-[A-Z][A-Z]*]} ]] &&
+        argf[1]+=' "signal:signals:_signals -P-"'
+  ;;
+  freebsd*|openbsd*|solaris2.<9->)
+    args+=(
+      '-s[send alternate signal]:signal:_signals'
+      '-k[send SIGKILL to each process]'
+    )
+  ;|
+  openbsd*|freebsd*)
+    args+=(
+      '-M[extra values from specified core file]:core file:_files'
+      '-N[extract name list from specified system]:system'
+    )
+  ;|
+  freebsd*) args+=( '-m[include mapped files]' ) ;;
+  solaris2.<9->)
+    args+=(
+      '-n[list only processes with non-blocking mandatory locks]'
+    )
+  ;;
+  solaris2.<10->)
+    args+=( '-d[report device usage for all minor nodes bound to same device]' )
+  ;;
+  sysv4 )
+    (( $+words[(r)-k] )) && argf=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' )
+  ;;
+esac
 
-  _arguments \
-    '(-f)-c[list all processes accessing files on the filesystem specified by name]' \
-    '(-c)-f[list all processes accessing named files]' \
-    '-k[kill processes accessing the file]' \
-    '-u[append the user name of the process owner to each PID]' \
-    $args \
-    $arg1 \
-    '*:file:_files'
-fi
+_arguments -s $args $argf