Skip to content

Commit a3ecfa3

Browse files
committed
fix: use _comp_compgen for COMPREPLY=($(compgen ... -- "$cur")) (v2)
1 parent 8da5dfb commit a3ecfa3

Some content is hidden

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

168 files changed

+781
-969
lines changed

completions/7z

+10-14
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ _comp_cmd_7z()
2626
opt=${cur:0:2} cur=${cur:2}
2727
fi
2828
if [[ $cur != *[@\!]* ]]; then
29-
COMPREPLY=($(compgen -P"$opt" -W '@ ! r@ r-@ r0@ r! r-! r0!' \
30-
-- "$cur"))
29+
_comp_compgen -- -P"$opt" -W '@ ! r@ r-@ r0@ r! r-! r0!'
3130
elif [[ $cur == ?(r@(-|0|))@* ]]; then
3231
_comp_compgen -c "${cur#*@}" -- -P"${opt}${cur%%@*}@" -f
3332
compopt -o filenames
@@ -53,8 +52,7 @@ _comp_cmd_7z()
5352
return
5453
;;
5554
-scs*)
56-
COMPREPLY=($(compgen -P"${cur:0:4}" -W 'UTF-8 WIN DOS' \
57-
-- "${cur:4}"))
55+
_comp_compgen -c "${cur:4}" -- -P"${cur:0:4}" -W 'UTF-8 WIN DOS'
5856
return
5957
;;
6058
-ssc?*)
@@ -63,14 +61,13 @@ _comp_cmd_7z()
6361
;;
6462
-t*)
6563
if [[ $mode == w ]]; then
66-
COMPREPLY=($(compgen -P"${cur:0:2}" -W '7z bzip2 gzip swfc
67-
tar wim xz zip' -- "${cur:2}"))
64+
_comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '7z bzip2 gzip
65+
swfc tar wim xz zip'
6866
else
69-
COMPREPLY=($(compgen -P"${cur:0:2}" -W '7z apm arj bzip2 cab
70-
chm cpio cramfs deb dmg elf fat flv gzip hfs iso lzh lzma
71-
lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar rpm
72-
squashfs swf swfc tar udf vhd wim xar xz z zip' \
73-
-- "${cur:2}"))
67+
_comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '7z apm arj
68+
bzip2 cab chm cpio cramfs deb dmg elf fat flv gzip hfs iso
69+
lzh lzma lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar
70+
rpm squashfs swf swfc tar udf vhd wim xar xz z zip'
7471
fi
7572
return
7673
;;
@@ -80,9 +77,8 @@ _comp_cmd_7z()
8077
esac
8178

8279
if [[ $cur == -* ]]; then
83-
COMPREPLY=($(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
84-
-o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \
85-
-- "$cur"))
80+
_comp_compgen -- -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
81+
-o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y'
8682
[[ ${COMPREPLY-} == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] ||
8783
compopt -o nospace
8884
return

completions/_dmesg

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ _comp_cmd_dmesg()
1515
return
1616
;;
1717
-f | --facility)
18-
COMPREPLY=($(compgen -W 'kern user mail daemon auth syslog lpr
19-
news' -- "$cur"))
18+
_comp_compgen -- -W 'kern user mail daemon auth syslog lpr news'
2019
return
2120
;;
2221
-l | --level | -n | --console-level)

completions/_mount.linux

+81-79
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ _comp_cmd_mount()
1818
cur="${cur##*,}"
1919
split=set
2020
fi
21-
COMPREPLY=($(compgen -W 'auto adfs affs autofs btrfs cifs coda
22-
cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus
23-
hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g
24-
proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs
25-
udf ufs umsdos usbfs vfat xfs' -- "$cur"))
21+
_comp_compgen -- -W 'auto adfs affs autofs btrfs cifs coda cramfs
22+
davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
23+
iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc
24+
qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
25+
ufs umsdos usbfs vfat xfs'
2626
_fstypes
2727
[[ $split ]] && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
2828
return
@@ -79,129 +79,131 @@ _comp_cmd_mount()
7979
# no completion if $cur is opt=smth
8080
[[ $cur == *=* ]] && return
8181
# mount options
82-
COMPREPLY=($(compgen -W 'loop {,a}sync {,no}atime {,no}auto
82+
_comp_compgen -- -W 'loop {,a}sync {,no}atime {,no}auto
8383
{,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync
8484
{,no}exec group {,no}iversion {,no}mand _netdev nofail
8585
{,no}relatime {,no}strictatime {,no}suid owner remount ro rw
86-
{,no}user users' -- "$cur"))
86+
{,no}user users'
8787
case "$fstype" in
8888
adfs | auto)
8989
_comp_compgen -a -- -W '{u,g}id= {own,oth}mask='
9090
;;&
9191
affs | auto)
92-
COMPREPLY+=($(compgen -W '{u,g}id= set{u,g}id= mode= protect
93-
usemp verbose prefix= volume= reserved= root= bs=
94-
{,no,usr,grp}quota' -- "$cur"))
92+
_comp_compgen -a -- -W '{u,g}id= set{u,g}id= mode= protect
93+
usemp verbose prefix= volume= reserved= root= bs=
94+
{,no,usr,grp}quota'
9595
;;&
9696
btrfs | auto)
97-
COMPREPLY+=($(compgen -W 'degraded subvol= subvolid= device=
98-
nodatasum nodatacow nobarrier max_inline= alloc_start=
99-
thread_pool= compress= compress-force= ssd noacl notreelog
100-
flushoncommit metadata_ratio= {,no}space_cache clear_cache
101-
user_subvol_rm_allowed autodefrag inode_cache' -- "$cur"))
97+
_comp_compgen -a -- -W 'degraded subvol= subvolid= device=
98+
nodatasum nodatacow nobarrier max_inline= alloc_start=
99+
thread_pool= compress= compress-force= ssd noacl
100+
notreelog flushoncommit metadata_ratio=
101+
{,no}space_cache clear_cache user_subvol_rm_allowed
102+
autodefrag inode_cache'
102103
;;&
103104
cifs | auto)
104-
COMPREPLY+=($(compgen -W 'user= password= credentials= {u,g}id=
105-
force{u,g}id port= servern= netbiosname= {file,dir}_mode=
106-
ip= domain= guest iocharset {,no}setuids {,no,dyn}perm
107-
directio {,no}mapchars {,no}intr hard soft noacl nocase sec=
108-
nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size=
109-
rwpidforward backup{u,g}id cache=' -- "$cur"))
105+
_comp_compgen -a -- -W 'user= password= credentials=
106+
{u,g}id= force{u,g}id port= servern= netbiosname=
107+
{file,dir}_mode= ip= domain= guest iocharset
108+
{,no}setuids {,no,dyn}perm directio {,no}mapchars
109+
{,no}intr hard soft noacl nocase sec= nobrl sfu
110+
{,no}serverino nounix nouser_xattr {r,w}size=
111+
rwpidforward backup{u,g}id cache='
110112
;;&
111113
davfs | auto)
112-
COMPREPLY+=($(compgen -W 'conf= {file,dir}_mode= {u,g}id=
113-
username=' -- "$cur"))
114+
_comp_compgen -a -- -W 'conf= {file,dir}_mode= {u,g}id=
115+
username='
114116
;;&
115117
ext[2-4] | auto)
116-
COMPREPLY+=($(compgen -W '{,no}acl bsddf minixdf check= debug
117-
errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
118-
nobh nouid32 oldalloc orlov res{u,g}id= sb=
119-
{,no}user_xattr' -- "$cur"))
118+
_comp_compgen -a -- -W '{,no}acl bsddf minixdf check= debug
119+
errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
120+
nobh nouid32 oldalloc orlov res{u,g}id= sb=
121+
{,no}user_xattr'
120122
;;&
121123
ext[34] | auto)
122-
COMPREPLY+=($(compgen -W 'journal= journal_dev= norecovery
123-
noload data= barrier= commit=' -- "$cur"))
124+
_comp_compgen -a -- -W 'journal= journal_dev= norecovery
125+
noload data= barrier= commit='
124126
;;&
125127
ext4 | auto)
126-
COMPREPLY+=($(compgen -W 'journal_checksum journal_async_commit
127-
nobarrier inode_readahead= stripe= {,no}delalloc abort
128-
{max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc
129-
{,no}discard nouid32 resize {,no}block_validity
130-
dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur"))
128+
_comp_compgen -a -- -W 'journal_checksum
129+
journal_async_commit nobarrier inode_readahead= stripe=
130+
{,no}delalloc abort {max,min}_batch_time=
131+
journal_ioprio= {,no}auto_da_alloc {,no}discard nouid32
132+
resize {,no}block_validity dioread_{,no}lock
133+
max_dir_size_kb= i_version'
131134
;;&
132135
msdos | umsdos | vfat | auto)
133-
COMPREPLY+=($(compgen -W 'blocksize= {u,g}id= {u,d,f}mask=
134-
allow_utime= check= codepage= conv= cvf_format= cvf_option=
135-
debug fat= iocharset= tz= quiet showexec sys_immutable flush
136-
usefree {,no}dots dotsOK=' -- "$cur"))
136+
_comp_compgen -a -- -W 'blocksize= {u,g}id= {u,d,f}mask=
137+
allow_utime= check= codepage= conv= cvf_format=
138+
cvf_option= debug fat= iocharset= tz= quiet showexec
139+
sys_immutable flush usefree {,no}dots dotsOK='
137140
;;&
138141
vfat | auto)
139-
COMPREPLY+=($(compgen -W 'uni_xlate posix nonumtail utf8
140-
shortname=' -- "$cur"))
142+
_comp_compgen -a -- -W 'uni_xlate posix nonumtail utf8
143+
shortname='
141144
;;&
142145
iso9660 | auto)
143-
COMPREPLY+=($(compgen -W 'norock nojoliet check= {u,g}id= map=
144-
mode= unhide block= conv= cruft session= sbsector=
145-
iocharset= utf8' -- "$cur"))
146+
_comp_compgen -a -- -W 'norock nojoliet check= {u,g}id=
147+
map= mode= unhide block= conv= cruft session= sbsector=
148+
iocharset= utf8'
146149
;;&
147150
jffs2 | auto)
148151
_comp_compgen -a -- -W 'compr= rp_size='
149152
;;&
150153
jfs | auto)
151-
COMPREPLY+=($(compgen -W 'iocharset= resize= {,no}integrity
152-
errors= {,no,usr,grp}quota' -- "$cur"))
154+
_comp_compgen -a -- -W 'iocharset= resize= {,no}integrity
155+
errors= {,no,usr,grp}quota'
153156
;;&
154157
nfs | nfs4 | auto)
155-
COMPREPLY+=($(compgen -W 'soft hard timeo= retrans= {r,w}size=
156-
{,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg
157-
retry= sec= {,no}sharecache {,no}resvport lookupcache=
158-
proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur"))
158+
_comp_compgen -a -- -W 'soft hard timeo= retrans= {r,w}size=
159+
{,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg
160+
retry= sec= {,no}sharecache {,no}resvport lookupcache=
161+
proto= port= {,no}intr {,no}cto {,nfs}vers='
159162
;;&
160163
nfs | auto)
161-
COMPREPLY+=($(compgen -W 'udp tcp rdma mount{port,proto,host}=
162-
mountvers= namlen={,no}lock {,no}acl {,no}rdirplus
163-
{,no}fsc' -- "$cur"))
164+
_comp_compgen -a -- -W 'udp tcp rdma mount{port,proto,host}=
165+
mountvers= namlen={,no}lock {,no}acl {,no}rdirplus
166+
{,no}fsc'
164167
;;&
165168
nfs4 | auto)
166-
COMPREPLY+=($(compgen -W 'clientaddr= {,no}migration' \
167-
-- "$cur"))
169+
_comp_compgen -a -- -W 'clientaddr= {,no}migration'
168170
;;&
169171
ntfs-3g)
170-
COMPREPLY+=($(compgen -W '{u,g}id= {u,f,d}mask= usermapping=
171-
permissions inherit locale= force {,no}recover
172-
ignore_case remove_hiberfile show_sys_files
173-
hide_{hid,dot}_files windows_names allow_other max_read=
174-
silent no_def_opts streams_interface= user_xattr efs_raw
175-
{,no}compression debug no_detach' -- "$cur"))
172+
_comp_compgen -a -- -W '{u,g}id= {u,f,d}mask= usermapping=
173+
permissions inherit locale= force {,no}recover
174+
ignore_case remove_hiberfile show_sys_files
175+
hide_{hid,dot}_files windows_names allow_other
176+
max_read= silent no_def_opts streams_interface=
177+
user_xattr efs_raw {,no}compression debug no_detach'
176178
;;&
177179
proc | auto)
178180
_comp_compgen -a -- -W '{u,g}id='
179181
;;&
180182
reiserfs | auto)
181-
COMPREPLY+=($(compgen -W 'conv hash= {,no_un}hashed_relocation
182-
noborder nolog notail replayonly resize= user_xattr acl
183-
barrier=' -- "$cur"))
183+
_comp_compgen -a -- -W 'conv hash=
184+
{,no_un}hashed_relocation noborder nolog notail
185+
replayonly resize= user_xattr acl barrier='
184186
;;&
185187
tmpfs | auto)
186-
COMPREPLY+=($(compgen -W 'size= nr_blocks= nr_inodes= mode=
187-
{u,g}id= mpol=' -- "$cur"))
188+
_comp_compgen -a -- -W 'size= nr_blocks= nr_inodes= mode=
189+
{u,g}id= mpol='
188190
;;&
189191
udf | auto)
190-
COMPREPLY+=($(compgen -W '{u,g}id= umask= unhide undelete
191-
nostrict iocharset bs= novrs session= anchor= volume=
192-
partition= lastblock= fileset= rootdir=' -- "$cur"))
192+
_comp_compgen -a -- -W '{u,g}id= umask= unhide undelete
193+
nostrict iocharset bs= novrs session= anchor= volume=
194+
partition= lastblock= fileset= rootdir='
193195
;;&
194196
usbfs | auto)
195-
COMPREPLY+=($(compgen -W 'dev{u,g}id= devmode= bus{u,g}id=
196-
busmode= list{u,g}id= listmode=' -- "$cur"))
197+
_comp_comgpen -a -- -W 'dev{u,g}id= devmode= bus{u,g}id=
198+
busmode= list{u,g}id= listmode='
197199
;;&
198200
xfs | auto)
199-
COMPREPLY+=($(compgen -W 'allocsize= {,no}attr2 barrier dmapi
200-
{,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep
201-
inode{32,64} {,no}largeio logbufs= logbsize= logdev=
202-
rtdev= mtpt= noalign norecovery nouuid osyncisosync
203-
{u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit= swidth=
204-
swalloc' -- "$cur"))
201+
_comp_compgen -a -- -W 'allocsize= {,no}attr2 barrier dmapi
202+
{,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep
203+
inode{32,64} {,no}largeio logbufs= logbsize= logdev=
204+
rtdev= mtpt= noalign norecovery nouuid osyncisosync
205+
{u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit=
206+
swidth= swalloc'
205207
;;&
206208
esac
207209
# COMP_WORDBREAKS is a real pain in the ass
@@ -213,10 +215,10 @@ _comp_cmd_mount()
213215
esac
214216

215217
if [[ $cur == -* ]]; then
216-
COMPREPLY=($(compgen -W '--version --help --verbose --all --fork
217-
--fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
218+
_comp_compgen -- -W '--version --help --verbose --all --fork --fake
219+
--internal-only -l --no-mtab --no-canonicalize --pass-fd -s
218220
--read-only --rw -L -U --types --test-opts --options --bind --rbind
219-
--move' -- "$cur"))
221+
--move'
220222
[[ ${COMPREPLY-} ]] && return
221223
fi
222224

completions/_nmcli

+14-21
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ _comp_cmd_nmcli()
7676

7777
if ((cword == 1)); then
7878
if [[ $cur == -* ]]; then
79-
COMPREPLY=($(compgen -W '--terse --pretty --mode --fields
80-
--escape --version --help' -- "$cur"))
79+
_comp_compgen -- -W '--terse --pretty --mode --fields --escape
80+
--version --help'
8181
else
8282
_comp_compgen -- -W "nm con dev"
8383
fi
@@ -110,8 +110,8 @@ _comp_cmd_nmcli()
110110
;;
111111
esac
112112

113-
COMPREPLY=($(compgen -W 'status permissions enable sleep
114-
wifi wwan wimax' -- "$cur"))
113+
_comp_compgen -- -W 'status permissions enable sleep wifi wwan
114+
wimax'
115115
;;
116116
con)
117117
case $command in
@@ -121,11 +121,9 @@ _comp_cmd_nmcli()
121121
;;
122122
up)
123123
if [[ $cur == -* ]]; then
124-
COMPREPLY=($(compgen -W '--nowait --timeout' \
125-
-- "$cur"))
124+
_comp_compgen -- -W '--nowait --timeout'
126125
else
127-
COMPREPLY=($(compgen -W 'id uuid iface ap nsp' \
128-
-- "$cur"))
126+
_comp_compgen -- -W 'id uuid iface ap nsp'
129127
fi
130128
return
131129
;;
@@ -139,8 +137,7 @@ _comp_cmd_nmcli()
139137
;;
140138
esac
141139

142-
COMPREPLY=($(compgen -W 'list status up down delete' \
143-
-- "$cur"))
140+
_comp_compgen -- -W 'list status up down delete'
144141
;;
145142
dev)
146143
case $command in
@@ -150,8 +147,7 @@ _comp_cmd_nmcli()
150147
;;
151148
disconnect)
152149
if [[ $cur == -* ]]; then
153-
COMPREPLY=($(compgen -W '--nowait --timeout' \
154-
-- "$cur"))
150+
_comp_compgen -- -W '--nowait --timeout'
155151
else
156152
_comp_compgen -- -W 'iface'
157153
fi
@@ -162,21 +158,19 @@ _comp_cmd_nmcli()
162158

163159
case $subcommand in
164160
list)
165-
COMPREPLY=($(compgen -W 'iface bssid' \
166-
-- "$cur"))
161+
_comp_compgen -- -W 'iface bssid'
167162
return
168163
;;
169164
connect)
170165
if [[ $cur == -* ]]; then
171-
COMPREPLY=($(compgen -W '--private
172-
--nowait --timeout' -- "$cur"))
166+
_comp_compgen -- -W '--private --nowait
167+
--timeout'
173168
else
174169
if [[ $prev == "connect" ]]; then
175170
_comp_cmd_nmcli__ap_ssid
176171
else
177-
COMPREPLY=($(compgen -W 'password
178-
wep-key-type iface bssid name' \
179-
-- "$cur"))
172+
_comp_compgen -- -W 'password
173+
wep-key-type iface bssid name'
180174
fi
181175
fi
182176
return
@@ -188,8 +182,7 @@ _comp_cmd_nmcli()
188182
;;
189183
esac
190184

191-
COMPREPLY=($(compgen -W 'status list disconnect wifi' \
192-
-- "$cur"))
185+
_comp_compgen -- -W 'status list disconnect wifi'
193186
;;
194187
esac
195188

0 commit comments

Comments
 (0)