about summary refs log tree commit diff
path: root/Completion/Unix/Command/_xargs
blob: f21784ef11a3b2fe45d22d1e1d1c67bd3859c1e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#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'
      '(-o --open-tty)'{-o,--open-tty}'[reopen stdin as /dev/tty in the child process before executing the command]'
      '--process-slot-var=[set environment variable to unique value in child processes]:variable:_parameters -g "*export*"'
      '(-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'