Skip to content

Commit b9eaa8f

Browse files
committed
fix: use _comp_compgen for COMPREPLY=($(compgen ... -- "...")) (v2)
1 parent b609caf commit b9eaa8f

File tree

10 files changed

+40
-45
lines changed

10 files changed

+40
-45
lines changed

completions/dd

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ _comp_cmd_dd()
1111
return
1212
;;
1313
conv=*)
14-
cur=${cur#*=}
15-
COMPREPLY=($(compgen -W 'ascii ebcdic ibm block unblock lcase
16-
ucase sparse swab sync excl nocreat notrunc noerror fdatasync
17-
fsync' -- "$cur"))
14+
_comp_compgen -c "${cur#*=}" -- -W 'ascii ebcdic ibm block unblock
15+
lcase ucase sparse swab sync excl nocreat notrunc noerror
16+
fdatasync fsync'
1817
return
1918
;;
2019
iflag=* | oflag=*)
21-
cur=${cur#*=}
22-
COMPREPLY=($(compgen -W 'append direct directory dsync sync
23-
fullblock nonblock noatime nocache noctty nofollow count_bytes
24-
skip_bytes seek_bytes' -- "$cur"))
20+
_comp_compgen -c "${cur#*=}" -- -W 'append direct directory dsync
21+
sync fullblock nonblock noatime nocache noctty nofollow
22+
count_bytes skip_bytes seek_bytes'
2523
return
2624
;;
2725
status=*)

completions/gprof

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ _comp_cmd_gprof()
1515
return
1616
;;
1717
-O*)
18-
cur=${cur:2}
19-
COMPREPLY=($(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \
20-
-- "$cur"))
18+
_comp_compgen -c "${cur:2}" -- -P -O -W 'auto bsd 4.4bsd magic
19+
prof'
2120
return
2221
;;
2322
esac

completions/java

+6-6
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ _comp_cmd_java()
185185
return
186186
;;
187187
-Xgc:*)
188-
COMPREPLY=($(compgen -W 'singlecon gencon singlepar genpar' \
189-
-- "${cur#*:}"))
188+
_comp_compgen -c "${cur#*:}" -- -W 'singlecon gencon singlepar
189+
genpar'
190190
return
191191
;;
192192
-Xgcprio:*)
193-
COMPREPLY=($(compgen -W 'throughput pausetime deterministic' \
194-
-- "${cur#*:}"))
193+
_comp_compgen -c "${cur#*:}" -- -W 'throughput pausetime
194+
deterministic'
195195
return
196196
;;
197197
-Xloggc:* | -Xverboselog:*)
@@ -203,8 +203,8 @@ _comp_cmd_java()
203203
return
204204
;;
205205
-Xverbose:*)
206-
COMPREPLY=($(compgen -W 'memory load jni cpuinfo codegen opt
207-
gcpause gcreport' -- "${cur#*:}"))
206+
_comp_compgen -c "${cur#*:}" -- -W 'memory load jni cpuinfo codegen
207+
opt gcpause gcreport'
208208
return
209209
;;
210210
-Xverify:*)

completions/modinfo

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ _comp_cmd_modinfo()
99
# shellcheck disable=SC2254
1010
case "$prev" in
1111
--field | -${noargopts}F)
12-
COMPREPLY=($(compgen -W 'alias author depends description
12+
_comp_compgen -c "${cur,,}" -- -W 'alias author depends description
1313
filename firmware intree license name parm release_date
1414
retpoline sig_hashalgo sig_key signat signer softdep srcversion
15-
staging vermagic version' -- "${cur,,}"))
15+
staging vermagic version'
1616
return
1717
;;
1818
--set-version | -${noargopts}k)

completions/pylint

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ _comp_cmd_pylint()
8484
--confidence)
8585
local prefix=
8686
[[ $cur == *,* ]] && prefix="${cur%,*},"
87-
COMPREPLY=($(compgen -W "HIGH INFERENCE INFERENCE_FAILURE
88-
UNDEFINED" -- "${cur##*,}"))
87+
_comp_compgen -c "${cur##*,}" -- -W "HIGH INFERENCE
88+
INFERENCE_FAILURE UNDEFINED"
8989
((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
9090
return
9191
;;

completions/pytest

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ _comp_cmd_pytest()
114114
fi
115115
done 2>/dev/null <"$file"
116116
((!${#COMPREPLY[@]})) ||
117-
COMPREPLY=($(compgen -P "$file::$class::" -W '"${COMPREPLY[@]}"' \
118-
-- "${cur##*:?(:)}"))
117+
_comp_compgen -c "${cur##*:?(:)}" -- -P "$file::$class::" \
118+
-W '"${COMPREPLY[@]}"'
119119
_comp_ltrim_colon_completions "$cur"
120120
return
121121
elif [[ $cur == *.py:* ]]; then
@@ -128,8 +128,8 @@ _comp_cmd_pytest()
128128
fi
129129
done 2>/dev/null <"$file"
130130
((!${#COMPREPLY[@]})) ||
131-
COMPREPLY=($(compgen -P "$file::" -W '"${COMPREPLY[@]}"' \
132-
-- "${cur##*.py:?(:)}"))
131+
_comp_compgen -c "${cur##*.py:?(:)}" -- -P "$file::" \
132+
-W '"${COMPREPLY[@]}"'
133133
_comp_ltrim_colon_completions "$cur"
134134
return
135135
fi

completions/rdesktop

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ _comp_cmd_rdesktop()
2727
-*r)
2828
case $cur in
2929
sound:*)
30-
COMPREPLY=($(compgen -W 'local off remote' \
31-
-- "${cur#sound:}"))
30+
_comp_compgen -c "${cur#sound:}" -- -W 'local off remote'
3231
;;
3332
*:*) ;;
3433

completions/tshark

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ _comp_cmd_tshark()
2626
_comp_cmd_tshark__prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
2727
tr '\n' ' ')"
2828
: ${prefix:=}
29-
COMPREPLY=($(compgen -P "$prefix" -W "$_comp_cmd_tshark__prefs" \
30-
-- "${cur:${#prefix}}"))
29+
_comp_compgen -c "${cur:${#prefix}}" -- -P "$prefix" \
30+
-W "$_comp_cmd_tshark__prefs"
3131
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
3232
fi
3333
return
@@ -103,8 +103,8 @@ _comp_cmd_tshark()
103103
if [[ ${cur:${#prefix}} == lua_script:* ]]; then
104104
_comp_compgen -c "${cur#*:}" filedir lua
105105
else
106-
COMPREPLY=($(compgen -P "$prefix" -W 'lua_script:' -- \
107-
"${cur:${#prefix}}"))
106+
_comp_compgen -c "${cur:${#prefix}}" -- -P "$prefix" \
107+
-W 'lua_script:'
108108
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
109109
fi
110110
return

completions/wget

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ _comp_cmd_wget()
4949
local lastopt=${cur/*,/} prevopt=
5050
[[ $cur == *,* ]] && prevopt=${cur%,*},
5151

52-
COMPREPLY=($(compgen -P "$prevopt" -X "@($excludes_str)" \
53-
-W 'unix windows nocontrol ascii lowercase uppercase' \
54-
-- "$lastopt"))
52+
_comp_compgen -c "$lastopt" -- -P "$prevopt" \
53+
-X "@($excludes_str)" \
54+
-W 'unix windows nocontrol ascii lowercase uppercase'
5555

5656
# +o nospace when no more valid option is possible (= append a space)
5757
local opt_as_arr=(${COMPREPLY[0]//,/ })
@@ -89,15 +89,15 @@ _comp_cmd_wget()
8989
local lastopt=${cur/*,/} prevopt=
9090
[[ $cur == *,* ]] && prevopt=${cur%,*},
9191

92-
COMPREPLY=($(compgen -P "$prevopt" -W 'a abbr acronym address
93-
applet area b base basefont bdo big blockquote body br button
94-
caption center cite code col colgroup dd del dir div dfn dl dt
95-
em fieldset font form frame frameset h6 head hr html i iframe
96-
img input ins isindex kbd label legend li link map menu meta
97-
noframes noscript object ol optgroup option p param pre q s
98-
samp script select small span strike strong style sub sup table
99-
tbody td textarea tfoot th thead title tr tt u ul var xmp' \
100-
-- "$lastopt"))
92+
_comp_compgen -c "$lastopt" -- -P "$prevopt" -W 'a abbr acronym
93+
address applet area b base basefont bdo big blockquote body br
94+
button caption center cite code col colgroup dd del dir div dfn
95+
dl dt em fieldset font form frame frameset h6 head hr html i
96+
iframe img input ins isindex kbd label legend li link map menu
97+
meta noframes noscript object ol optgroup option p param pre q
98+
s samp script select small span strike strong style sub sup
99+
table tbody td textarea tfoot th thead title tr tt u ul var
100+
xmp'
101101
return
102102
;;
103103
--tries | --timeout | --dns-timeout | --connect-timeout | \

completions/xgamma

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ _comp_cmd_xgamma()
3333
local t screens=$(xrandr --query 2>/dev/null | command sed -ne \
3434
'/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
3535
t="${cur#:}"
36-
COMPREPLY=($(compgen -P "${t%.*}." -W '$screens' -- \
37-
"${cur##*.}"))
36+
_comp_compgen -c "${cur##*.}" -- -P "${t%.*}." -W '$screens'
3837
elif [[ $cur != *:* ]]; then
3938
# complete hostnames
4039
_known_hosts_real -c -- "$cur"

0 commit comments

Comments
 (0)