Skip to content

Commit

Permalink
fix(_comp_count_args): skip reassembling cword and words
Browse files Browse the repository at this point in the history
These completions induce reassembling `cword` and `words` inside
`_comp_count_args`, but they are likely to be intended to be the same
as outside `cword` and `words`.  We just skip the reassembling by
dropping `-n ""` or `-n :`.
  • Loading branch information
akinomyoga committed Sep 2, 2023
1 parent 29398ef commit 3127703
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion completions/chmod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _comp_cmd_chmod()
fi

local ret
_comp_count_args -n "" -i "$modearg"
_comp_count_args -i "$modearg"

case $ret in
1) ;; # mode
Expand Down
2 changes: 1 addition & 1 deletion completions/chown
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _comp_cmd_chown()
local ret

# The first argument is a usergroup; the rest are filedir.
_comp_count_args -n :
_comp_count_args

if ((ret == 1)); then
_comp_compgen_usergroup -u
Expand Down
2 changes: 1 addition & 1 deletion completions/cryptsetup
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _comp_cmd_cryptsetup()
local ret
if _comp_get_first_arg; then
local arg=$ret
_comp_count_args -n "" -a "-${noargopts}[chslSbopitTdM]"
_comp_count_args -a "-${noargopts}[chslSbopitTdM]"
local args=$ret
case $arg in
open | create | luksOpen | loopaesOpen | tcryptOpen)
Expand Down
10 changes: 5 additions & 5 deletions completions/hcitool
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _comp_cmd_hcitool()
if _comp_get_first_arg; then
case $ret in
name | info | dc | rssi | lq | afh | auth | key | clkoff | lst)
_comp_count_args -n ""
_comp_count_args
if ((ret == 2)); then
_comp_cmd_hcitool__bluetooth_addresses
fi
Expand All @@ -58,30 +58,30 @@ _comp_cmd_hcitool()
if [[ $cur == -* ]]; then
_comp_compgen -- -W '--role --pkt-type'
else
_comp_count_args -n ""
_comp_count_args
if ((ret == 2)); then
_comp_cmd_hcitool__bluetooth_addresses
fi
fi
;;
sr)
_comp_count_args -n ""
_comp_count_args
if ((ret == 2)); then
_comp_cmd_hcitool__bluetooth_addresses
else
_comp_compgen -- -W 'master slave'
fi
;;
cpt)
_comp_count_args -n ""
_comp_count_args
if ((ret == 2)); then
_comp_cmd_hcitool__bluetooth_addresses
else
_comp_cmd_hcitool__bluetooth_packet_types
fi
;;
tpl | enc | clock)
_comp_count_args -n ""
_comp_count_args
if ((ret == 2)); then
_comp_cmd_hcitool__bluetooth_addresses
else
Expand Down
2 changes: 1 addition & 1 deletion completions/mkinitrd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _comp_cmd_mkinitrd()
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
local ret
_comp_count_args -n ""
_comp_count_args

case $ret in
1)
Expand Down
2 changes: 1 addition & 1 deletion completions/patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ _comp_cmd_patch()
fi

local ret
_comp_count_args -n ""
_comp_count_args
case $ret in
1)
_comp_compgen_filedir
Expand Down
2 changes: 1 addition & 1 deletion completions/quota
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ _comp_cmd_setquota()
_comp_cmd_quota__parse_help "$1"
else
local ret
_comp_count_args -n ""
_comp_count_args

case $ret in
1)
Expand Down
2 changes: 1 addition & 1 deletion completions/zopflipng
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _comp_cmd_zopflipng()
if [[ ${words[*]} != *\ --prefix=* ]]; then
# 2 png args only if --prefix not given
local ret
_comp_count_args -n ""
_comp_count_args
((ret < 3)) && _comp_compgen_filedir png
else
# otherwise arbitrary number of png args
Expand Down

0 comments on commit 3127703

Please sign in to comment.