Skip to content

Commit 5fe66d8

Browse files
akinomyogascop
andcommitted
refactor: reduce trivial _comp_compgen -- -W '"${COMPREPLY[@]}"'
There are also more non-trivial cases where COMPREPLY is first constructed and then filtered by `_comp_compgen -- -W '"${COMPREPLY[@]}"'`, but they would conflict with forthcoming other PRs for _comp_compgen rewrite. We will address them after finishing the _comp_compgen-related PRs. Co-authored-by: Ville Skyttä <[email protected]>
1 parent 2c9a1a9 commit 5fe66d8

File tree

6 files changed

+7
-20
lines changed

6 files changed

+7
-20
lines changed

completions/ifup

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ _comp_cmd_ifupdown()
3333

3434
if ((args == 1)); then
3535
_configured_interfaces
36-
((${#COMPREPLY[@]})) &&
37-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
3836
fi
3937
} &&
4038
complete -F _comp_cmd_ifupdown ifup ifdown ifquery ifstatus

completions/ip

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ _comp_cmd_ip()
334334
if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
335335
_available_interfaces
336336
if [[ $prev != dev ]]; then
337-
COMPREPLY+=(dev)
338-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
337+
_comp_compgen -a -W dev
339338
fi
340339
fi
341340
;;

completions/smartctl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ _comp_cmd_smartctl__device()
44
{
55
case $cur in
66
areca* | 3ware* | megaraid* | cciss*)
7-
# shellcheck disable=SC2054
8-
COMPREPLY=(${cur%%,*},{0..31})
9-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
7+
_comp_compgen -- -W '${cur%%,*},{0..31}'
108
;;
119
hpt*)
12-
# shellcheck disable=SC2054
13-
COMPREPLY=(hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5})
14-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
10+
_comp_compgen -- -W 'hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}'
1511
;;
1612
*)
1713
COMPREPLY=($(compgen -W "ata scsi sat usbcypress usbjmicron

completions/tune2fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ _comp_cmd_tune2fs()
1515
;;
1616
-*g)
1717
_gids
18-
((${#COMPREPLY[@]})) &&
19-
_comp_compgen -- -g -W '"${COMPREPLY[@]}"'
18+
_comp_compgen -a -- -g
2019
return
2120
;;
2221
-*M)
@@ -40,8 +39,7 @@ _comp_cmd_tune2fs()
4039
;;
4140
-*u)
4241
_uids
43-
((${#COMPREPLY[@]})) &&
44-
_comp_compgen -- -u -W '"${COMPREPLY[@]}"'
42+
_comp_compgen -a -- -u
4543
return
4644
;;
4745
-*U)

completions/useradd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ _comp_cmd_useradd()
3030
;;
3131
--gid | -${noargopts}g)
3232
_gids
33-
_comp_compgen -aR -- -g
34-
((${#COMPREPLY[@]})) &&
35-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
33+
_comp_compgen -a -- -g
3634
return
3735
;;
3836
--groups | -${noargopts}G)

completions/usermod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ _comp_cmd_usermod()
2626
;;
2727
--gid | -${noargopts}g)
2828
_gids
29-
_comp_compgen -aR -- -g
30-
((${#COMPREPLY[@]})) &&
31-
_comp_compgen -- -W '"${COMPREPLY[@]}"'
29+
_comp_compgen -a -- -g
3230
return
3331
;;
3432
--groups | -${noargopts}G)

0 commit comments

Comments
 (0)