about summary refs log tree commit diff
path: root/Completion/Unix/Command/_xargs
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2015-05-03 16:53:47 +0200
committerOliver Kiddle <opk@zsh.org>2015-05-03 16:53:57 +0200
commitab7ec8d9851fea8230e1ccfba284c5bfaf457d88 (patch)
tree837b14c838b96728ebdb530eb20d35737ef8419b /Completion/Unix/Command/_xargs
parentb29278c69a67089ba225a98478069eb3f32ab4e6 (diff)
downloadzsh-ab7ec8d9851fea8230e1ccfba284c5bfaf457d88.tar.gz
zsh-ab7ec8d9851fea8230e1ccfba284c5bfaf457d88.tar.xz
zsh-ab7ec8d9851fea8230e1ccfba284c5bfaf457d88.zip
35011: update completions for some common Unix commands,
in particular improving FreeBSD support
Diffstat (limited to 'Completion/Unix/Command/_xargs')
-rw-r--r--Completion/Unix/Command/_xargs74
1 files changed, 61 insertions, 13 deletions
diff --git a/Completion/Unix/Command/_xargs b/Completion/Unix/Command/_xargs
index f727ed8b7..d8c0a0ec2 100644
--- a/Completion/Unix/Command/_xargs
+++ b/Completion/Unix/Command/_xargs
@@ -1,15 +1,63 @@
-#compdef xargs
-
-_arguments \
-  '(-t)-p[prompt user for each command]' \
-  '(-p)-t[verbose - echo each command]' \
-  '-x[exit if max size exceeded]' \
-  -{e-,E}':end-of-file string:' \
-  '(-x -I)-i-:replacement string for lines:' \
-  '(-x -i)-I:replacement string for lines:' \
-  '(-n -L -x)-l-:number of input lines:' \
-  '(-n -l)-L:number of input lines:' \
-  '(-l -L)-n-:maximum number of arguments:' \
-  '-s-:maximum command line length:' \
+#compdef xargs gxargs
+
+local args variant
+
+args=(
+  '(-l -L --max-lines -n --max-args -s --max-chars)'{-n+,--max-args=}'[specify maximum number of arguments for each line]:number of arguments' \
+  '(-l -L --max-lines -n --max-args -s --max-chars)'{-s+,--max-chars=}'[specify maximum characters per command line]:maximum command line length'
+  '(-p --verbose -t --interactive)'{-p,--interactive}'[prompt user for each command]'
+  '(-p --verbose -t --interactive)'{-t,--verbose}'[verbose - echo each command]'
+  '(-x --exit)'{-x,--exit}'[exit if max size exceeded]'
+)
+
+_pick_variant -r variant gnu=GNU $OSTYPE --version
+
+case $variant in
+  gnu|darwin*|freebsd*|netbsd*|openbsd*)
+    args+=(
+      '(--max-procs -P)'{-P,--max-procs}'[parallel mode]:maximum processes' '!-r'
+    )
+  ;|
+  dragonfly*|darwin*|freebsd*|netbsd*|openbsd*)
+    args=( "${(@)args:#(|\(*\))(|\*)--*}"
+      '-0[expect NUL characters as input separators]'
+      '-J[specify marker for position of arguments]:marker'
+      '-R[specify maximum arguments that -I will replace in]:replacements'
+    )
+  ;|
+  freebsd*|netbsd*)
+    args+=(
+      '-S[space that -I can use for replacements]:size (bytes) [255]'
+    )
+  ;;
+  solaris*|gnu)
+    args+=(
+      '(-x -I)'{-i-,--replace}'[specify replacement string for command line]::replacement string'
+      '(-n -L -x)-l-[call program for every number of lines]:number of input lines'
+      '(-E -e --eof)'{-e-,--eof=}'[specify EOF marker]:end-of-file marker'
+    )
+  ;|
+  solaris*) args=( "${(@)args:#(|\(*\))(|\*)--*}" ) ;|
+  solaris2.<11->)
+    args+=( '-0[expect NUL characters as input separators]' )
+  ;;
+  gnu)
+    args+=(
+      '(-a --arg-file)'{-a+,--arg-file=}'[read input items from specified file]:file:_files'
+      '(-0 --null -d --delimiter)'{-0,--null}'[expect NUL characters as input separators]'
+      '(-d --delimiter -0 --null)'{-d+,--delimiter=}'[specify delimiter of input items]:delimiter'
+      '(-l -L --max-lines -n --max-args -s --max-chars)--max-lines=-[call program for every number of lines]::number of input lines'
+      '(-r --no-run-if-empty)'{-r,--no-run-if-empty}"[don't run command in absence of input]"
+      '(- *)--help[show help information]'
+      '(- *)--version[show version information]'
+      '--show-limits[show OS imposed limits to command-line length]'
+    )
+  ;;
+esac
+
+_arguments -s $args \
+  '-E[specify EOF marker]:end-of-file marker' \
+  '(-x -i)-I[specify replacement string for command line]:replacement string' \
+  '(-n -l)-L[call program for every number of lines]:number of input lines' \
   '(-):command: _command_names -e' \
   '*::args: _normal'