Skip to content

Commit

Permalink
fix(*): handle the case of prev=-oOPTARG
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 19, 2022
1 parent 2c5ac76 commit d9690e1
Show file tree
Hide file tree
Showing 122 changed files with 832 additions and 514 deletions.
8 changes: 5 additions & 3 deletions completions/a2x
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ _a2x()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[aDd]*)'
# shellcheck disable=SC2254
case $prev in
--attribute | --asciidoc-opts | --dblatex-opts | --fop-opts | --help | \
--version | --xsltproc-opts | -!(-*)[ah])
--version | --xsltproc-opts | -${otherflags}[ah])
return
;;
--destination-dir | --icons-dir | -!(-*)D)
--destination-dir | --icons-dir | -${otherflags}D)
_filedir -d
return
;;
--doctype | -!(-*)d)
--doctype | -${otherflags}d)
_comp_xfunc asciidoc doctype
return
;;
Expand Down
6 changes: 4 additions & 2 deletions completions/acpi
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ _acpi()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local otherflags='!(-*|*[d]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | -!(-*)[hv])
--help | --version | -${otherflags}[hv])
return
;;
--directory | -!(-*)d)
--directory | -${otherflags}d)
_filedir -d
return
;;
Expand Down
4 changes: 3 additions & 1 deletion completions/apt-cache
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ _apt_cache()
return
fi

local otherflags='!(-*|*[cps]*)'
# shellcheck disable=SC2254
case $prev in
--config-file | --pkg-cache | --src-cache | -!(-*)[cps])
--config-file | --pkg-cache | --src-cache | -${otherflags}[cps])
_filedir
return
;;
Expand Down
8 changes: 5 additions & 3 deletions completions/apt-get
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ _apt_get()
return
fi

local otherflags='!(-*|*[eoct]*)'
# shellcheck disable=SC2254
case $prev in
--error-on | --help | --version | --option | -!(-*)[ehvo])
--error-on | --help | --version | --option | -${otherflags}[ehvo])
return
;;
--config-file | -!(-*)c)
--config-file | -${otherflags}c)
_filedir
return
;;
--target-release | --default-release | -!(-*)t)
--target-release | --default-release | -${otherflags}t)
COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \
's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \
-- "$cur"))
Expand Down
8 changes: 5 additions & 3 deletions completions/apt-mark
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ _comp_cmd_apt_mark()
return
fi

local otherflags='!(-*|*[ocf]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | --option | -!(-*)[hvo])
--help | --version | --option | -${otherflags}[hvo])
return
;;
--config-file | -!(-*)c)
--config-file | -${otherflags}c)
_filedir conf
return
;;
--file | -!(-*)f)
--file | -${otherflags}f)
_filedir
return
;;
Expand Down
10 changes: 6 additions & 4 deletions completions/aptitude
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,26 @@ _aptitude()
esac
fi

local otherflags='!(-*|*[SwFoOt]*)'
# shellcheck disable=SC2254
case $prev in
# don't complete anything if these options are found
autoclean | clean | forget-new | search | upgrade | update | keep-all)
return
;;
-!(-*)S)
-${otherflags}S)
_filedir
return
;;
--display-format | --width | -!(-*)[wFo])
--display-format | --width | -${otherflags}[wFo])
return
;;
--sort | -!(-*)O)
--sort | -${otherflags}O)
COMPREPLY=($(compgen -W 'installsize installsizechange debsize
name priority version' -- "$cur"))
return
;;
--target-release | --default-release | -!(-*)t)
--target-release | --default-release | -${otherflags}t)
COMPREPLY=($(apt-cache policy |
command grep "release.o=Debian,a=$cur" |
command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null))
Expand Down
12 changes: 7 additions & 5 deletions completions/arp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ _arp()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local otherflags='!(-*|*[iApfHt]*)'
# shellcheck disable=SC2254
case $prev in
--device | -!(-*)i)
--device | -${otherflags}i)
_available_interfaces -a
return
;;
--protocol | -!(-*)[Ap])
--protocol | -${otherflags}[Ap])
# TODO protocol/address family
return
;;
--file | -!(-*)f)
--file | -${otherflags}f)
_filedir
return
;;
--hw-type | -!(-*)[Ht])
--hw-type | -${otherflags}[Ht])
# TODO: parse from --help output?
COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \
dlci fddi hippi irda x25 eui64' -- "$cur"))
Expand All @@ -34,7 +36,7 @@ _arp()
fi

local args
_count_args "" "@(--device|--protocol|--file|--hw-type|-!(-*)[iApfHt])"
_count_args "" "@(--device|--protocol|--file|--hw-type|-${otherflags}[iApfHt])"
case $args in
1)
local ips=$("$1" -an | command sed -ne \
Expand Down
14 changes: 8 additions & 6 deletions completions/asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@ _asciidoc()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[abfdo]*)'
# shellcheck disable=SC2254
case $prev in
--attribute | -!(-*)a)
--attribute | -${otherflags}a)
return
;;
--backend | -!(-*)b)
--backend | -${otherflags}b)
COMPREPLY=($(compgen -W 'docbook html4 xhtml11' -- "$cur"))
return
;;
--conf-file | -!(-*)f)
--conf-file | -${otherflags}f)
_filedir conf
return
;;
--doctype | -!(-*)d)
--doctype | -${otherflags}d)
_comp_xfunc_asciidoc_doctype
return
;;
--help | -!(-*)h)
--help | -${otherflags}h)
COMPREPLY=($(compgen -W 'manpage syntax topics' -- "$cur"))
return
;;
--out-file | -!(-*)o)
--out-file | -${otherflags}o)
_filedir
return
;;
Expand Down
6 changes: 4 additions & 2 deletions completions/autoscan
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ _autoscan()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[BI]*)'
# shellcheck disable=SC2254
case "$prev" in
--help | --version | -!(-*)[hV])
--help | --version | -${otherflags}[hV])
return
;;
--prepend-include | --include | -!(-*)[BI])
--prepend-include | --include | -${otherflags}[BI])
_filedir -d
return
;;
Expand Down
8 changes: 5 additions & 3 deletions completions/avahi-browse
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ _comp_cmd_avahi_browse()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[D]*)'
# shellcheck disable=SC2254
case $prev in
--domain | -!(-*)D)
--domain | -${otherflags}D)
return
;;
--help | --version | -!(-*)[hV]*)
--help | --version | -${otherflags}[hV]*)
return
;;
esac
Expand All @@ -27,7 +29,7 @@ _comp_cmd_avahi_browse()
local word
for word in "${words[@]}"; do
case $word in
--all | --browse-domains | --dump-db | -!(-*)[aDb]*)
--all | --browse-domains | --dump-db | -${otherflags}[aDb]*)
return
;;
esac
Expand Down
6 changes: 4 additions & 2 deletions completions/bzip2
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ _bzip2()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local otherflags='!(-*|*[bpn]*)'
# shellcheck disable=SC2254
case $prev in
--help | -!(-*)[bhp])
--help | -${otherflags}[bhp])
return
;;
-!(-*)n)
-${otherflags}n)
COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
return
;;
Expand Down
6 changes: 4 additions & 2 deletions completions/ccache
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ _ccache()
[[ ${COMP_WORDS[i]} == -*[oFM] ]] && ((i++))
done

local otherflags='!(-*|*[FMo]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | --max-files | --max-size | -!(-*)[hVFM])
--help | --version | --max-files | --max-size | -${otherflags}[hVFM])
return
;;
--set-config | -!(-*)o)
--set-config | -${otherflags}o)
if [[ $cur != *=* ]]; then
COMPREPLY=($(compgen -S = -W "$($1 -p 2>/dev/null |
awk '$3 = "=" { print $2 }')" -- "$cur"))
Expand Down
12 changes: 7 additions & 5 deletions completions/ccze
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ _ccze()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[acFmop]*)'
# shellcheck disable=SC2254
case $prev in
-'?' | --help | --usage | -V | --version)
return
;;
--argument | --color | -!(-*)[ac])
--argument | --color | -${otherflags}[ac])
# TODO?
return
;;
--rcfile | -!(-*)F)
--rcfile | -${otherflags}F)
_filedir
return
;;
--mode | -!(-*)m)
--mode | -${otherflags}m)
COMPREPLY=($(compgen -W "curses ansi html" -- "$cur"))
return
;;
--option | -!(-*)o)
--option | -${otherflags}o)
local -a opts=(scroll wordcolor lookups transparent cssfile)
COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur"))
return
;;
--plugin | -!(-*)p)
--plugin | -${otherflags}p)
COMPREPLY=($(compgen -W '$("$1" --list-plugins | command \
sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p")' \
-- "$cur"))
Expand Down
6 changes: 4 additions & 2 deletions completions/chage
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ _chage()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[dEImMWR]*)'
# shellcheck disable=SC2254
case $prev in
--lastday | --expiredate | --help | --inactive | --mindays | --maxdays | \
--warndays | -!(-*)[dEhImMW])
--warndays | -${otherflags}[dEhImMW])
return
;;
--root | -!(-*)R)
--root | -${otherflags}R)
_filedir -d
return
;;
Expand Down
8 changes: 5 additions & 3 deletions completions/chpasswd
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ _chpasswd()
local cur prev words cword split comp_args
_comp_initialize -s -- "$@" || return

local otherflags='!(-*|*[csR]*)'
# shellcheck disable=SC2254
case $prev in
--crypt | -!(-*)c)
--crypt | -${otherflags}c)
COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' \
-- "$cur"))
return
;;
--sha-rounds | -!(-*)s)
--sha-rounds | -${otherflags}s)
return
;;
--root | -!(-*)R)
--root | -${otherflags}R)
_filedir -d
return
;;
Expand Down
6 changes: 4 additions & 2 deletions completions/chrpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ _chrpath()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local otherflags='!(-*|*[r]*)'
# shellcheck disable=SC2254
case $prev in
--version | --help | -!(-*)[vh])
--version | --help | -${otherflags}[vh])
return
;;
--replace | -!(-*)r)
--replace | -${otherflags}r)
_filedir -d
return
;;
Expand Down
8 changes: 5 additions & 3 deletions completions/cpio
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ _cpio()
_comp_initialize -s -n : -- "$@" || return

# --name value style option
local otherflags='!(-*|*[HEFIR]*)'
# shellcheck disable=SC2254
case $prev in
--format | -!(-*)H)
--format | -${otherflags}H)
COMPREPLY=($(compgen -W \
'bin odc newc crc tar ustar hpbin hpodc' -- "$cur"))
return
;;
--file | --pattern-file | -!(-*)[EFI])
--file | --pattern-file | -${otherflags}[EFI])
_filedir
return
;;
--owner | -!(-*)R)
--owner | -${otherflags}R)
_usergroup
return
;;
Expand Down
Loading

0 comments on commit d9690e1

Please sign in to comment.