about summary refs log tree commit diff
path: root/Completion/Unix/Command/_chown
diff options
context:
space:
mode:
authorMatthew Martin <phy1729@gmail.com>2019-04-22 22:04:24 -0500
committerMatthew Martin <phy1729@gmail.com>2019-04-22 22:04:24 -0500
commita4f44972076ac86bde7f8b96c18b10807d580965 (patch)
treee0bbd37e3c0f5eda842a7d58955ae9a9157afe0e /Completion/Unix/Command/_chown
parent64d13738357c9b9c212adbe17f271716abbcf6ea (diff)
downloadzsh-a4f44972076ac86bde7f8b96c18b10807d580965.tar.gz
zsh-a4f44972076ac86bde7f8b96c18b10807d580965.tar.xz
zsh-a4f44972076ac86bde7f8b96c18b10807d580965.zip
44242: Completion: Use _pick_variant -b to detect builtins
Diffstat (limited to 'Completion/Unix/Command/_chown')
-rw-r--r--Completion/Unix/Command/_chown97
1 files changed, 61 insertions, 36 deletions
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index a97a0e0bf..8fde02096 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -1,43 +1,68 @@
 #compdef chown chgrp gchown=chown gchgrp=chgrp zf_chown=chown zf_chgrp=chgrp
 
-local curcontext="$curcontext" state line expl ret=1
+local curcontext="$curcontext" state line expl ret=1 variant
 local suf usr grp req deref pattern arg args
 
-if _pick_variant gnu=Free\ Soft unix --version; then
-  args=(
-    '(-c --changes -v --verbose)'{-c,--changes}'[report each change made]'
-    '(-c --changes -v --verbose)'{-v,--verbose}'[output info for every file processed]'
-    '(-h --no-dereference)--dereference[dereference symlinks]'
-    '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]'
-    '(-f --silent --quiet)'{-f,--silent,--quiet}"[don't report errors]"
-    '--preserve-root[fail to operate recursively on /]'
-    '--reference=[copy ownership of specified file]:file:_files'
-    '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]'
-    '(-H -L -P)-L[follow all symlinks]'
-    '(-H -L -P)-H[follow symlinks on the command line]'
-    '(-H -L -P)-P[do not follow symlinks (default)]'
-    '(- : *)--help[display help information]'
-    '(- : *)--version[display version information]'
-  )    
-  [[ $service = chown ]] &&
-      args+=( '--from=[restrict changes to files by current ownership]: :->owner' )
-else
-  args=(
-    "-h[operate on symlinks them self]"
-    '-R[change files and directories recursively]'
-    '(-H -L -P)-L[follow all symlinks]'
-    '(-H -L -P)-H[follow symlinks on the command line]'
-    '(-H -L -P)-P[do not follow symlinks (default)]'
-  )
-  for pattern arg in \
-    '(dragonfly|freebsd)*' "-x[don't traverse file systems]" \
-    '(darwin|dragonfly|(free|net)bsd|solaris)*' "-f[don't report errors]" \
-    '(darwin|dragonfly|(free|net)bsd)*' '-v[output info for every file processed]' \
-    'solaris2.<11->' '-s[owner and/or group are Windows SID strings]'
-  do
-    [[ $OSTYPE = $~pattern ]] && args+=( $arg )
-  done
-fi
+_pick_variant -r variant -b zsh gnu=Free\ Soft $OSTYPE --version
+case "$variant" in
+  gnu)
+    args=(
+      '(-c --changes -v --verbose)'{-c,--changes}'[report each change made]'
+      '(-c --changes -v --verbose)'{-v,--verbose}'[output info for every file processed]'
+      '(-h --no-dereference)--dereference[dereference symlinks]'
+      '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]'
+      '(-f --silent --quiet)'{-f,--silent,--quiet}"[don't report errors]"
+      '--preserve-root[fail to operate recursively on /]'
+      '--reference=[copy ownership of specified file]:file:_files'
+      '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]'
+      '(-H -L -P)-L[follow all symlinks]'
+      '(-H -L -P)-H[follow symlinks on the command line]'
+      '(-H -L -P)-P[do not follow symlinks (default)]'
+      '(- : *)--help[display help information]'
+      '(- : *)--version[display version information]'
+    )
+    [[ $service = chown ]] &&
+        args+=( '--from=[restrict changes to files by current ownership]: :->owner' )
+    ;;
+  *)
+    args=(
+      '-h[operate on symlinks them self]'
+      '-R[change files and directories recursively]'
+    )
+    ;|
+  zsh)
+    args+=(
+      '-s[enable paranoid behavior]'
+    )
+    ;;
+  *)
+    args+=(
+      '(-H -L -P)-L[follow all symlinks]'
+      '(-H -L -P)-H[follow symlinks on the command line]'
+      '(-H -L -P)-P[do not follow symlinks (default)]'
+    )
+    ;|
+  dragonfly*|freebsd*)
+    args+=(
+      "-x[don't traverse file systems]"
+    )
+    ;|
+  darwin*|dragonfly*|freebsd*|netbsd*|solaris*)
+    args+=(
+      "-f[don't report errors]"
+    )
+    ;|
+  darwin*|dragonfly*|freebsd*|netbsd*)
+    args+=(
+       '-v[output info for every file processed]'
+    )
+    ;|
+  solaris2.<11->)
+    args+=(
+      '-s[owner and/or group are Windows SID strings]'
+    )
+    ;;
+esac
 
 (( $+words[(r)--reference*] )) || args+=( '(--reference)1: :->owner' )
 _arguments -C -s "$args[@]" '*: :->files' && ret=0