1#compdef patch gpatch 2 3if (( ! $+_patch_args )); then 4 local help="$(LC_ALL=C $words[1] --help 2>&1)" 5 local -A optionmap 6 local arg 7 local comp_p='compadd "$expl[@]" -S0 -r "1-9" - ""' 8 9 [[ "$help" = *--[^h]* || "$help" = *\[-c\|-e\|-n\]* ]] && arg=+ 10 11 optionmap=( 12 '*( -p NUM[, ]|\[-p (num|strip-count)\])*' '(--strip)-p+[number of path prefix components to strip]:number of path prefix components to strip:'"{$comp_p}" 13 '*\[--strip\[=strip-count\]\]*' '(-p)--strip=-[number of path prefix components to strip]:number of path prefix components to strip:'"{$comp_p}" 14 '* --strip=NUM[, ]*' '(-p)--strip=[number of path prefix components to strip]:number of path prefix components to strip:'"{$comp_p}" 15 16 '*\[-Fmax-fuzz\]*' '(--fuzz)-F-[specify the maximum fuzz factor]:maximum fuzz factor:' 17 '*(\[-F max-fuzz\]| -F LINES[, ])*' '(--fuzz)-F+[specify the maximum fuzz factor]:maximum fuzz factor:' 18 '*(\[--fuzz=max-fuzz\]| --fuzz( |=)LINES[, ])*' '(-F)--fuzz=[specify the maximum fuzz factor]:maximum fuzz factor:' 19 20 '*(\[-[a-zA-Z]#l[a-zA-Z]#\]| -l[, ])*' '(--ignore-whitespace)-l[ignore white space changes]' 21 '*(\[--ignore-whitespace\]| --ignore-whitespace[, ])*' '(-l)--ignore-whitespace[ignore white space changes]' 22 23 '*(\[-[a-zA-Z]#c[a-zA-Z]#\]| -c[, ]|\[-c\|)*' '( -e -n -u --context --ed --normal --unified)-c[interpret context diff]' 24 '*(\[-[a-zA-Z]#e[a-zA-Z]#\]| -e[, ]|\|-e\|)*' '(-c -n -u --context --ed --normal --unified)-e[interpret ed script]' 25 '*(\[-[a-zA-Z]#n[a-zA-Z]#\]| -n[, ]|\|-n\])*' '(-c -e -u --context --ed --normal --unified)-n[interpret normal diff]' 26 '*(\[-[a-zA-Z]#u[a-zA-Z]#\]| -u[, ])*' '(-c -e -n --context --ed --normal --unified)-u[interpret unified diff]' 27 '*(\[--context\]| --context[, ])*' '(-c -e -n -u --ed --normal --unified)--context[interpret context diff]' 28 '*(\[--ed\]| --ed[, ])*' '(-c -e -n -u --context --normal --unified)--ed[interpret ed script]' 29 '*(\[--normal\]| --normal[, ])*' '(-c -e -n -u --context --ed --unified)--normal[interpret normal diff]' 30 '*(\[--unified\]| --unified[, ])*' '(-c -e -n -u --context --ed --normal )--unified[interpret unified diff]' 31 32 '*(\[-[a-zA-Z]#N[a-zA-Z]#\]| -N[, ])*' '(--forward)-N[ignore reverse patches]' 33 '*(\[--forward\]| --forward[, ])*' '(-N)--forward[ignore reverse patches]' 34 '*(\[-[a-zA-Z]#R[a-zA-Z]#\]| -R[, ])*' '(--reverse)-R[reverse mode]' 35 '*(\[--reverse\]| --reverse[, ])*' '(-R)--reverse[reverse mode]' 36 37 '*(\[-i patchfile\]| -i PATCHFILE[, ])*' '*-i+[specify input patch file]:patch file:_files' 38 '* --input=PATCHFILE[, ]*' '*--input=[specify input patch file]:patch file:_files' 39 40 '*(\[-o out-file\]| -o FILE[, ]|\[-o outfile\])*' "(--output)-o${arg}[output file]:output file:_files" 41 '*(\[--output=out-file\]| --output=FILE[, ])*' '(-o)--output=[output file]:output file:_files' 42 '*(\[-r rej-name\]| -r FILE[, ]|\[-r rejectfile\])*' "(--reject-file)-r${arg}[reject file]:reject file:_files" 43 '*(\[--reject-file=rej-name\]| --reject-file=FILE[, ])*' '(-r)--reject-file=[reject file]:reject file:_files' 44 45 '*(\[-D symbol\]| -D NAME[, ]|\[-D define\])*' '(--ifdef)-D+[cpp symbol]:symbol:' 46 '*(\[--ifdef=symbol\]| --ifdef=NAME[, ])*' '(-D)--ifdef=[cpp symbol]:symbol:' 47 48 '* --merge*' '(--reject-file --reject-format -r)--merge[merge using conflict markers instead of creating reject files]' 49 50 '*(\[-[a-zA-Z]#E[a-zA-Z]#\]| -E[, ])*' '(--remove-empty-files)-E[remove empty files]' 51 '*(\[--remove-empty-files\]| --remove-empty-files[, ])*' '(-E)--remove-empty-files[remove empty files]' 52 53 '* -Z[, ]*' '( -T --set-utc --set-time)-Z[assume timestamp as UTC]' 54 '* -T[, ]*' '(-Z --set-utc --set-time)-T[assume timestamp as local time]' 55 '* --set-utc[, ]*' '(-Z -T --set-time)--set-utc[assume timestamp as UTC]' 56 '* --set-time[, ]*' '(-Z -T --set-utc )--set-time[assume timestamp as local time]' 57 58 '* --quoting-style=WORD[, ]*' '--quoting-style=[quoting style]:quoting style:(literal shell shell-always c escape)' 59 60 '*(\[-[a-zA-Z]#b[a-zA-Z]#\]| -b[, ])*' '(--backup)-b[backup original]' 61 '* --backup[, ]*' '(-b)--backup[backup original]' 62 '* --backup-if-mismatch[, ]*' '(--no-backup-if-mismatch)--backup-if-mismatch[back up if not match exactly]' 63 '* --no-backup-if-mismatch[, ]*' '(--backup-if-mismatch)--no-backup-if-mismatch[back up only if otherwise requested]' 64 65 '*(\[-V {numbered,existing,simple}\]| -V STYLE[, ])*' "(--version-control)-V${arg}[backup method]:backup method:(numbered existing simple)" 66 '*\[-V t \| nil \| never\]*' '(-B)-V+[specify backup method]:backup method:((t\:numbered nil\:existing never\:simple))' 67 '*(\[--version-control={numbered,existing,simple}\]| --version-control=STYLE[, ])*' '(-V)--version-control=[backup method]:backup method:(numbered existing simple)' 68 69 '*(\[-B backup-prefix\]| -B PREFIX[, ])*' "(--prefix)-B${arg}[specify backup prefix]:backup prefix:" 70 '*(\[--prefix=backup-prefix\]| --prefix=PREFIX[, ])*' '(-B)--prefix=[specify backup prefix]:backup prefix:' 71 '* -Y PREFIX[, ]*' '(--basename-prefix)-Y+[specify backup basename prefix]:backup basename prefix:' 72 '* --basename-prefix=PREFIX[, ]*' '(-Y)--basename-prefix=[specify backup basename prefix]:backup basename prefix:' 73 '*\[-b backup-ext\]*' "( -z --suffix)-b${arg}[specify backup suffix]:backup suffix:(.bak)" 74 '*\[-z backup-ext\]*' '(--suffix)-z+[specify backup suffix]:backup suffix [.orig]:(.bak)' 75 '* -z SUFFIX[, ]*' '(-b --suffix)-z+[specify backup suffix]:backup suffix:(.bak)' 76 '*(\[--suffix=backup-ext\]| --suffix=SUFFIX[, ])*' '(-b -z )--suffix=[specify backup suffix]:backup suffix:(.bak)' 77 78 '* -g NUM[, ]*' '(--get)-g+[get from RCS etc.]:number:((1\:get -1\:ask))' 79 '* --get=NUM[, ]*' '(-g)--get=[get from RCS etc.]:number:((1\:get -1\:ask))' 80 81 '* -g --get *' '(-G --get --no-get)-g[get from RCS or SCCS] 82(-g -G --no-get)--get[get from RCS or SCCS]' 83 '* -G --no-get *' '(-g --get --no-get)-G[don'\''t get from RCS or SCCS] 84(-g -G --get)--no-get[don'\''t get from RCS or SCCS]' 85 86 '*(\[-[a-zA-Z]#f[a-zA-Z]#\]| -f[, ])*' '( -t --force --batch)-f[force mode]' 87 '*(\[-[a-zA-Z]#t[a-zA-Z]#\]| -t[, ])*' '(-f --force --batch)-t[batch mode]' 88 '*(\[--force\]| --force[, ])*' '(-f -t --batch)--force[force mode]' 89 '*(\[--batch\]| --batch[, ])*' '(-f -t --force )--batch[batch mode]' 90 91 '*(\[-[a-zA-Z]#s[a-zA-Z]#\]| -s[, ])*' '( --quiet --silent)-s[silent mode]' 92 '*(\[--quiet\]| --quiet[, ])*' '(-s --silent)--quiet[silent mode]' 93 '*(\[--silent\]|--silent[, ])*' '(-s --quiet )--silent[silent mode]' 94 95 '* --verbose[, ]*' '--verbose[verbose mode]' 96 97 '*(\[-[a-zA-Z]#C[a-zA-Z]#\])*' '(--check)-C[only check that the patch would apply cleanly]' 98 '*\[--check\]*' '(-C)--check[only check that the patch would apply cleanly]' 99 '* --dry-run[, ]*' '--dry-run[only check that the patch would apply cleanly]' 100 101 '*--posix*' '--posix[POSIX mode]' 102 103 '*(\[-d directory\]| -d DIR[, ]|\[-d dir\])*' '(--directory)-d+[change the working directory]:chdir to:_files -/' 104 '*(\[--directory=directory\]| --directory=DIR[, ])*' '(-d)--directory=[change the working directory]:chdir to:_files -/' 105 106 '* --reject-format=*' '--reject-format=[specify format of rejects]:format:(context unified)' 107 '* --read-only=*' '--read-only=[specify how to handle read-only input files]:behaviour [warn]: (ignore warn fail)' 108 109 '* --binary[, ]*' '--binary[binary mode]' 110 111 '*(\[-[a-zA-Z]#v[a-zA-Z]#\]| -v[, ])*' '(-)-v[print version]' 112 '*(\[--version\]| --version[, ])*' '(-)--version[print version]' 113 '* --help[, ]*' '(-)--help[print help message]' 114 115 '*\[-[a-zA-Z]#S[a-zA-Z]#\]*' '*-S[ignore this patch]' 116 '*\[--skip\]*' '*--skip[ignore this patch]' 117 118 '*\[--index-first\]*' '--index-first[take Index: line precedence]' 119 120 '* --use-index-line *' '--use-index-line[deal with Index: line]' 121 '* --patch-root=DIR *' '--patch-root=[restrict paths]:patch root:_files -/' 122 123 '* -U *' '(--unified-reject-files)-U[create unified reject files]' 124 '* --unified-reject-files *' '(-U)--unified-reject-files[create unified reject files]' 125 '* --global-reject-file=file *' '--global-reject-file=[put all rejects into one file]:file:_files' 126 ) 127 _patch_args=( 128 ${arg:+"-s"} 129 ${(fF)optionmap[(K)"$help"]} 130 ) 131fi 132 133_arguments "${(@)_patch_args}" ':original file:_files' ':patch file:_files' 134