summaryrefslogtreecommitdiffstats
path: root/completions/patch
diff options
context:
space:
mode:
Diffstat (limited to 'completions/patch')
-rw-r--r--completions/patch53
1 files changed, 27 insertions, 26 deletions
diff --git a/completions/patch b/completions/patch
index e883d9c..bba184c 100644
--- a/completions/patch
+++ b/completions/patch
@@ -1,70 +1,71 @@
# patch(1) completion -*- shell-script -*-
-_patch()
+_comp_cmd_patch()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[pDBYzgFiorVd]*)'
+ # shellcheck disable=SC2254
case $prev in
--strip | --ifdef | --prefix | --basename-prefix | --suffix | --get | \
- -!(-*)[pDBYzg])
+ -${noargopts}[pDBYzg])
return
;;
- --fuzz | -!(-*)F)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ --fuzz | -${noargopts}F)
+ _comp_compgen -- -W '{0..3}'
return
;;
- --input | -!(-*)i)
- _filedir '@(?(d)patch|dif?(f))'
+ --input | -${noargopts}i)
+ _comp_compgen_filedir '@(?(d)patch|dif?(f))'
return
;;
- --output | --reject-file | -!(-*)[or])
+ --output | --reject-file | -${noargopts}[or])
[[ ! $cur || $cur == - ]] && COMPREPLY=(-)
- _filedir
+ _comp_compgen -a filedir
return
;;
--quoting-style)
- COMPREPLY=($(compgen -W 'literal shell shell-always c escape' \
- -- "$cur"))
+ _comp_compgen -- -W 'literal shell shell-always c escape'
return
;;
- --version-control | -!(-*)V)
- COMPREPLY=($(compgen -W 'simple numbered existing' -- "$cur"))
+ --version-control | -${noargopts}V)
+ _comp_compgen -- -W 'simple numbered existing'
return
;;
- --directory | -!(-*)d)
- _filedir -d
+ --directory | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
--reject-format)
- COMPREPLY=($(compgen -W 'context unified' -- "$cur"))
+ _comp_compgen -- -W 'context unified'
return
;;
--read-only)
- COMPREPLY=($(compgen -W 'ignore warn fail' -- "$cur"))
+ _comp_compgen -- -W 'ignore warn fail'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local args
- _count_args
- case $args in
+ local REPLY
+ _comp_count_args
+ case $REPLY in
1)
- _filedir
+ _comp_compgen_filedir
;;
2)
- _filedir '@(?(d)patch|dif?(f))'
+ _comp_compgen_filedir '@(?(d)patch|dif?(f))'
;;
esac
} &&
- complete -F _patch patch
+ complete -F _comp_cmd_patch patch
# ex: filetype=sh