summaryrefslogtreecommitdiffstats
path: root/completions/xz
diff options
context:
space:
mode:
Diffstat (limited to 'completions/xz')
-rw-r--r--completions/xz43
1 files changed, 23 insertions, 20 deletions
diff --git a/completions/xz b/completions/xz
index 73958c5..8d6c53b 100644
--- a/completions/xz
+++ b/completions/xz
@@ -1,56 +1,59 @@
# xz(1) completion -*- shell-script -*-
-_xz()
+_comp_cmd_xz()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local xspec="*.@(xz|lzma|txz|tlz)"
+ local noargopts='!(-*|*[CFTMS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --decompress | --list | --test | -!(-*)[dlt]*)
+ --decompress | --list | --test | -${noargopts}[dlt]*)
xspec="!"$xspec
;;
--files | --files0)
- _filedir
+ _comp_compgen_filedir
return
;;
- --check | -!(-*)C)
- COMPREPLY=($(compgen -W 'crc32 crc64 sha256 none' -- "$cur"))
+ --check | -${noargopts}C)
+ _comp_compgen -- -W 'crc32 crc64 sha256 none'
return
;;
- --format | -!(-*)F)
- COMPREPLY=($(compgen -W 'auto xz lzma raw' -- "$cur"))
+ --format | -${noargopts}F)
+ _comp_compgen -- -W 'auto xz lzma raw'
return
;;
- --threads | -!(-*)T)
- COMPREPLY=($(compgen -W "{0..$(_ncpus)}" -- "$cur"))
+ --threads | -${noargopts}T)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{0..$REPLY}"
return
;;
--memlimit | --memlimit-compress | --memlimit-decompress | --memory | \
- --suffix | --delta | --lzma1 | --lzma2 | -!(-*)[MS])
+ --suffix | --delta | --lzma1 | --lzma2 | -${noargopts}[MS])
return
;;
- --help | --long-help | --version | --info-memory | -!(-*)[hHV])
+ --help | --long-help | --version | --info-memory | -${noargopts}[hHV])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \
- -- "$cur"))
+ _comp_compgen_help -- --long-help
+ _comp_compgen -a -- -W '{-1..-9}'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _xz xz pxz
+ complete -F _comp_cmd_xz xz pxz
# ex: filetype=sh