Skip to content

Commit a805a2f

Browse files
authored
Merge pull request #955 from akinomyoga/_comp_compgen-1
fix: use _comp_compgen for `COMPREPLY=($(compgen ...))`
2 parents 1930f81 + 7e49307 commit a805a2f

File tree

276 files changed

+820
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+820
-855
lines changed

bash_completion

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ _comp_compgen()
533533

534534
local _result
535535
_result=$(
536-
IFS=$_ifs
537-
compgen "$@" ${_cur:+-- "$_cur"}
536+
IFS=$_ifs compgen "$@" ${_cur:+-- "$_cur"}
538537
) || {
539538
local _status=$?
540539
if [[ $_append ]]; then

completions/7z

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _comp_cmd_7z()
66
_comp_initialize -n = -- "$@" || return
77

88
if ((cword == 1)); then
9-
COMPREPLY=($(compgen -W 'a b d e h i l rn t u x' -- "$cur"))
9+
_comp_compgen -- -W 'a b d e h i l rn t u x'
1010
return
1111
fi
1212

@@ -15,7 +15,7 @@ _comp_cmd_7z()
1515

1616
case $cur in
1717
-ao*)
18-
COMPREPLY=($(compgen -P"${cur:0:3}" -W 'a s t u' -- "${cur:3}"))
18+
_comp_compgen -c "${cur:3}" -- -P"${cur:0:3}" -W 'a s t u'
1919
return
2020
;;
2121
-?(a)[ix]*)
@@ -29,35 +29,27 @@ _comp_cmd_7z()
2929
COMPREPLY=($(compgen -P"$opt" -W '@ ! r@ r-@ r0@ r! r-! r0!' \
3030
-- "$cur"))
3131
elif [[ $cur == ?(r@(-|0|))@* ]]; then
32-
local IFS=$' \t\n' reset=$(shopt -po noglob)
33-
set -o noglob
34-
COMPREPLY=($(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}"))
35-
$reset
32+
_comp_compgen -c "${cur#*@}" -- -P"${opt}${cur%%@*}@" -f
3633
compopt -o filenames
3734
fi
3835
return
3936
;;
4037
-mhe=* | -mhc=* | -ms=* | -mt=*)
41-
COMPREPLY=($(compgen -W 'on off' -- "${cur#*=}"))
38+
_comp_compgen -c "${cur#*=}" -- -W 'on off'
4239
return
4340
;;
4441
-mx=*)
45-
COMPREPLY=($(compgen -W '0 1 3 5 7 9' -- "${cur#*=}"))
42+
_comp_compgen -c "${cur#*=}" -- -W '0 1 3 5 7 9'
4643
return
4744
;;
4845
-o* | -w?*)
49-
local reset=$(shopt -po noglob)
50-
set -o noglob
5146
compopt -o filenames
52-
local IFS=$'\n'
53-
COMPREPLY=($(compgen -d -P"${cur:0:2}" -S/ -- "${cur:2}"))
54-
_comp_unlocal IFS
55-
$reset
47+
_comp_compgen -c "${cur:2}" -- -d -P"${cur:0:2}" -S/
5648
compopt -o nospace
5749
return
5850
;;
5951
-r?*)
60-
COMPREPLY=($(compgen -P"${cur:0:2}" -W '- 0' -- "${cur:2}"))
52+
_comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '- 0'
6153
return
6254
;;
6355
-scs*)
@@ -66,7 +58,7 @@ _comp_cmd_7z()
6658
return
6759
;;
6860
-ssc?*)
69-
COMPREPLY=($(compgen -P"${cur:0:4}" -W '-' -- "${cur:4}"))
61+
_comp_compgen -c "${cur:4}" -- -P"${cur:0:4}" -W '-'
7062
return
7163
;;
7264
-t*)

completions/_adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ _comp_cmd_adb()
4444
tmp+=(devices connect disconnect sideload)
4545
fi
4646
((${#tmp[@]})) &&
47-
COMPREPLY=($(compgen -W '"${tmp[@]}"' -- "$cur"))
47+
_comp_compgen -- -W '"${tmp[@]}"'
4848
return
4949
fi
5050

@@ -62,7 +62,7 @@ _comp_cmd_adb()
6262
_parse_help -)' -- "$cur"))
6363
;;
6464
reboot)
65-
COMPREPLY=($(compgen -W 'bootloader recovery' -- "$cur"))
65+
_comp_compgen -- -W 'bootloader recovery'
6666
;;
6767
esac
6868
} &&

completions/_cal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _comp_cmd_cal()
1111
case $prev in
1212
-m)
1313
if [[ $OSTYPE == *bsd* ]]; then
14-
COMPREPLY=($(compgen -W '{1..12}' -- "$cur"))
14+
_comp_compgen -- -W '{1..12}'
1515
return
1616
fi
1717
;;
@@ -32,7 +32,7 @@ _comp_cmd_cal()
3232

3333
local args
3434
_count_args
35-
((args == 1)) && COMPREPLY=($(compgen -W '{1..12}' -- "$cur"))
35+
((args == 1)) && _comp_compgen -- -W '{1..12}'
3636
} &&
3737
complete -F _comp_cmd_cal cal ncal
3838

completions/_dmesg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _comp_cmd_dmesg()
2020
return
2121
;;
2222
-l | --level | -n | --console-level)
23-
COMPREPLY=($(compgen -W '{1..8}' -- "$cur"))
23+
_comp_compgen -- -W '{1..8}'
2424
return
2525
;;
2626
esac

completions/_eject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _comp_cmd_eject()
1313
return
1414
;;
1515
-a | --auto | -i | --manualeject)
16-
COMPREPLY=($(compgen -W 'on off' -- "$cur"))
16+
_comp_compgen -- -W 'on off'
1717
return
1818
;;
1919
esac

completions/_ionice

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ _comp_cmd_ionice()
3737

3838
case $prev in
3939
-c)
40-
COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
40+
_comp_compgen -- -W '{0..3}'
4141
return
4242
;;
4343
-n)
44-
COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
44+
_comp_compgen -- -W '{0..7}'
4545
return
4646
;;
4747
-p)

completions/_mock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ _comp_cmd_mock()
5050
return
5151
;;
5252
--enable-plugin | --disable-plugin)
53-
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
53+
_comp_compgen -- -W "$plugins"
5454
return
5555
;;
5656
esac

completions/_modules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ _comp_cmd_module()
6060
options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' |
6161
awk '{print $2}' | command sed -e 's/|/ /g' | sort)"
6262

63-
COMPREPLY=($(compgen -W "$options" -- "$cur"))
63+
_comp_compgen -- -W "$options"
6464

6565
elif ((cword == 2)); then
6666
case $prev in

completions/_mount.linux

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _comp_cmd_mount()
3232
return
3333
;;
3434
-p | --pass-fd)
35-
COMPREPLY=($(compgen -W '{0..9}'))
35+
_comp_compgen -R -- -W '{0..9}'
3636
compopt -o nospace
3737
return
3838
;;
@@ -86,7 +86,7 @@ _comp_cmd_mount()
8686
{,no}user users' -- "$cur"))
8787
case "$fstype" in
8888
adfs | auto)
89-
COMPREPLY+=($(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur"))
89+
_comp_compgen -a -- -W '{u,g}id= {own,oth}mask='
9090
;;&
9191
affs | auto)
9292
COMPREPLY+=($(compgen -W '{u,g}id= set{u,g}id= mode= protect
@@ -145,7 +145,7 @@ _comp_cmd_mount()
145145
iocharset= utf8' -- "$cur"))
146146
;;&
147147
jffs2 | auto)
148-
COMPREPLY+=($(compgen -W 'compr= rp_size=' -- "$cur"))
148+
_comp_compgen -a -- -W 'compr= rp_size='
149149
;;&
150150
jfs | auto)
151151
COMPREPLY+=($(compgen -W 'iocharset= resize= {,no}integrity
@@ -175,7 +175,7 @@ _comp_cmd_mount()
175175
{,no}compression debug no_detach' -- "$cur"))
176176
;;&
177177
proc | auto)
178-
COMPREPLY+=($(compgen -W '{u,g}id=' -- "$cur"))
178+
_comp_compgen -a -- -W '{u,g}id='
179179
;;&
180180
reiserfs | auto)
181181
COMPREPLY+=($(compgen -W 'conv hash= {,no_un}hashed_relocation

0 commit comments

Comments
 (0)