about summary refs log tree commit diff
path: root/Completion/Unix/Command/_rm
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/_rm
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/_rm')
-rw-r--r--Completion/Unix/Command/_rm86
1 files changed, 49 insertions, 37 deletions
diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm
index aa24a3fd6..dfd3a394a 100644
--- a/Completion/Unix/Command/_rm
+++ b/Completion/Unix/Command/_rm
@@ -1,5 +1,6 @@
 #compdef rm grm zf_rm
 
+local variant
 declare -a opts args
 args=(
   '(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]'
@@ -7,47 +8,58 @@ args=(
   '(-r -R --recursive)'{-r,-R,--recursive}'[remove directories and their contents recursively]'
   '*:: :->file'
 )
-if _pick_variant gnu=gnu unix --help; then
-  opts+=(-S)
-  args+=(
-    '(-i --interactive)-I[prompt when removing many files]'
-    '(-i -I)--interactive=-[prompt under given condition (defaulting to always)]::when:((once\:"prompt when removing many files"
-                                                                                         always\:"prompt before every removal"))'
-    '--one-file-system[stay within filesystems of files given as arguments]'
-    '(                   --preserve-root)--no-preserve-root[do not treat / specially]'
-    '(--no-preserve-root                )--preserve-root[do not remove / (default)]'
-    '(-d --dir)'{-d,--dir}'[remove directories as well]'
-    '(-v --verbose)'{-v,--verbose}'[explain what is being done]'
-    '(- *)--help[display help message and exit]'
-    '(- *)--version[output version information and exit]'
-  )
-else
-  args=(${args:#*)--*\[*})
-  case $OSTYPE in
-    darwin*|dragonfly*|freebsd*|netbsd*|openbsd*)
-      args+=(
-        '-d[remove directories as well]'
-        '-P[overwrite files before deleting them]'
-        '-v[explain what is being done]'
-      )
+_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help
+case $variant; in
+  gnu)
+    opts+=(-S)
+    args+=(
+      '(-i --interactive)-I[prompt when removing many files]'
+      '(-i -I)--interactive=-[prompt under given condition (defaulting to always)]::when:((once\:"prompt when removing many files"
+                                                                                           always\:"prompt before every removal"))'
+      '--one-file-system[stay within filesystems of files given as arguments]'
+      '(                   --preserve-root)--no-preserve-root[do not treat / specially]'
+      '(--no-preserve-root                )--preserve-root[do not remove / (default)]'
+      '(-d --dir)'{-d,--dir}'[remove directories as well]'
+      '(-v --verbose)'{-v,--verbose}'[explain what is being done]'
+      '(- *)--help[display help message and exit]'
+      '(- *)--version[output version information and exit]'
+    )
+    ;;
+  *)
+    args=(${args:#*)--*\[*})
+    ;|
+  darwin*|dragonfly*|freebsd*|netbsd*|openbsd*|zsh)
+    args+=(
+      '-d[remove directories as well]'
+    )
     ;|
-    darwin*|dragonfly*|freebsd*|netbsd*)
-      args+=(
-        '-W[attempt to undelete named files]'
-      )
+  zsh)
+    args+=(
+      '-s[enable paranoid behavior]'
+    )
+    ;;
+  darwin*|dragonfly*|freebsd*|netbsd*|openbsd*)
+    args+=(
+      '-P[overwrite files before deleting them]'
+      '-v[explain what is being done]'
+    )
     ;|
-    dragonfly*|freebsd*|netbsd*)
-      args+=(
-        "-x[don't cross file systems when removing a hierarchy]"
-      )
+  darwin*|dragonfly*|freebsd*|netbsd*)
+    args+=(
+      '-W[attempt to undelete named files]'
+    )
     ;|
-    dragonfly*|freebsd*)
-      args+=(
-        '(-i)-I[prompt when removing many files]'
-      )
+  dragonfly*|freebsd*|netbsd*)
+    args+=(
+      "-x[don't cross file systems when removing a hierarchy]"
+    )
+    ;|
+  dragonfly*|freebsd*)
+    args+=(
+      '(-i)-I[prompt when removing many files]'
+    )
     ;;
-  esac
-fi
+esac
 
 local curcontext=$curcontext state line ret=1
 declare -A opt_args