Skip to content

Commit

Permalink
Merge pull request #862 from akinomyoga/reportbug-otherflags
Browse files Browse the repository at this point in the history
fix(completions/*): skip `prev` of the form `-oOPTARG`
  • Loading branch information
scop committed Dec 22, 2022
2 parents dd880e3 + ab7c0b4 commit a392580
Show file tree
Hide file tree
Showing 123 changed files with 840 additions and 520 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 noargopts='!(-*|*[aDd]*)'
# shellcheck disable=SC2254
case $prev in
--attribute | --asciidoc-opts | --dblatex-opts | --fop-opts | --help | \
--version | --xsltproc-opts | -!(-*)[ah])
--version | --xsltproc-opts | -${noargopts}[ah])
return
;;
--destination-dir | --icons-dir | -!(-*)D)
--destination-dir | --icons-dir | -${noargopts}D)
_filedir -d
return
;;
--doctype | -!(-*)d)
--doctype | -${noargopts}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 noargopts='!(-*|*[d]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | -!(-*)[hv])
--help | --version | -${noargopts}[hv])
return
;;
--directory | -!(-*)d)
--directory | -${noargopts}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 noargopts='!(-*|*[cps]*)'
# shellcheck disable=SC2254
case $prev in
--config-file | --pkg-cache | --src-cache | -!(-*)[cps])
--config-file | --pkg-cache | --src-cache | -${noargopts}[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 noargopts='!(-*|*[eoct]*)'
# shellcheck disable=SC2254
case $prev in
--error-on | --help | --version | --option | -!(-*)[ehvo])
--error-on | --help | --version | --option | -${noargopts}[ehvo])
return
;;
--config-file | -!(-*)c)
--config-file | -${noargopts}c)
_filedir
return
;;
--target-release | --default-release | -!(-*)t)
--target-release | --default-release | -${noargopts}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 noargopts='!(-*|*[ocf]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | --option | -!(-*)[hvo])
--help | --version | --option | -${noargopts}[hvo])
return
;;
--config-file | -!(-*)c)
--config-file | -${noargopts}c)
_filedir conf
return
;;
--file | -!(-*)f)
--file | -${noargopts}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 noargopts='!(-*|*[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)
-${noargopts}S)
_filedir
return
;;
--display-format | --width | -!(-*)[wFo])
--display-format | --width | -${noargopts}[wFo])
return
;;
--sort | -!(-*)O)
--sort | -${noargopts}O)
COMPREPLY=($(compgen -W 'installsize installsizechange debsize
name priority version' -- "$cur"))
return
;;
--target-release | --default-release | -!(-*)t)
--target-release | --default-release | -${noargopts}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 noargopts='!(-*|*[iApfHt]*)'
# shellcheck disable=SC2254
case $prev in
--device | -!(-*)i)
--device | -${noargopts}i)
_available_interfaces -a
return
;;
--protocol | -!(-*)[Ap])
--protocol | -${noargopts}[Ap])
# TODO protocol/address family
return
;;
--file | -!(-*)f)
--file | -${noargopts}f)
_filedir
return
;;
--hw-type | -!(-*)[Ht])
--hw-type | -${noargopts}[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|-${noargopts}[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 noargopts='!(-*|*[abfdo]*)'
# shellcheck disable=SC2254
case $prev in
--attribute | -!(-*)a)
--attribute | -${noargopts}a)
return
;;
--backend | -!(-*)b)
--backend | -${noargopts}b)
COMPREPLY=($(compgen -W 'docbook html4 xhtml11' -- "$cur"))
return
;;
--conf-file | -!(-*)f)
--conf-file | -${noargopts}f)
_filedir conf
return
;;
--doctype | -!(-*)d)
--doctype | -${noargopts}d)
_comp_xfunc_asciidoc_doctype
return
;;
--help | -!(-*)h)
--help | -${noargopts}h)
COMPREPLY=($(compgen -W 'manpage syntax topics' -- "$cur"))
return
;;
--out-file | -!(-*)o)
--out-file | -${noargopts}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 noargopts='!(-*|*[BI]*)'
# shellcheck disable=SC2254
case "$prev" in
--help | --version | -!(-*)[hV])
--help | --version | -${noargopts}[hV])
return
;;
--prepend-include | --include | -!(-*)[BI])
--prepend-include | --include | -${noargopts}[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 noargopts='!(-*|*[D]*)'
# shellcheck disable=SC2254
case $prev in
--domain | -!(-*)D)
--domain | -${noargopts}D)
return
;;
--help | --version | -!(-*)[hV]*)
--help | --version | -${noargopts}[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 | -${noargopts}[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 noargopts='!(-*|*[bpn]*)'
# shellcheck disable=SC2254
case $prev in
--help | -!(-*)[bhp])
--help | -${noargopts}[bhp])
return
;;
-!(-*)n)
-${noargopts}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 noargopts='!(-*|*[FMo]*)'
# shellcheck disable=SC2254
case $prev in
--help | --version | --max-files | --max-size | -!(-*)[hVFM])
--help | --version | --max-files | --max-size | -${noargopts}[hVFM])
return
;;
--set-config | -!(-*)o)
--set-config | -${noargopts}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 noargopts='!(-*|*[acFmop]*)'
# shellcheck disable=SC2254
case $prev in
-'?' | --help | --usage | -V | --version)
return
;;
--argument | --color | -!(-*)[ac])
--argument | --color | -${noargopts}[ac])
# TODO?
return
;;
--rcfile | -!(-*)F)
--rcfile | -${noargopts}F)
_filedir
return
;;
--mode | -!(-*)m)
--mode | -${noargopts}m)
COMPREPLY=($(compgen -W "curses ansi html" -- "$cur"))
return
;;
--option | -!(-*)o)
--option | -${noargopts}o)
local -a opts=(scroll wordcolor lookups transparent cssfile)
COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur"))
return
;;
--plugin | -!(-*)p)
--plugin | -${noargopts}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 noargopts='!(-*|*[dEImMWR]*)'
# shellcheck disable=SC2254
case $prev in
--lastday | --expiredate | --help | --inactive | --mindays | --maxdays | \
--warndays | -!(-*)[dEhImMW])
--warndays | -${noargopts}[dEhImMW])
return
;;
--root | -!(-*)R)
--root | -${noargopts}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 noargopts='!(-*|*[csR]*)'
# shellcheck disable=SC2254
case $prev in
--crypt | -!(-*)c)
--crypt | -${noargopts}c)
COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' \
-- "$cur"))
return
;;
--sha-rounds | -!(-*)s)
--sha-rounds | -${noargopts}s)
return
;;
--root | -!(-*)R)
--root | -${noargopts}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 noargopts='!(-*|*[r]*)'
# shellcheck disable=SC2254
case $prev in
--version | --help | -!(-*)[vh])
--version | --help | -${noargopts}[vh])
return
;;
--replace | -!(-*)r)
--replace | -${noargopts}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 noargopts='!(-*|*[HEFIR]*)'
# shellcheck disable=SC2254
case $prev in
--format | -!(-*)H)
--format | -${noargopts}H)
COMPREPLY=($(compgen -W \
'bin odc newc crc tar ustar hpbin hpodc' -- "$cur"))
return
;;
--file | --pattern-file | -!(-*)[EFI])
--file | --pattern-file | -${noargopts}[EFI])
_filedir
return
;;
--owner | -!(-*)R)
--owner | -${noargopts}R)
_usergroup
return
;;
Expand Down
Loading

0 comments on commit a392580

Please sign in to comment.