Skip to content

Commit ad49f8a

Browse files
committed
refactor: use _comp_compgen -c for filedir
1 parent f45b104 commit ad49f8a

28 files changed

+41
-77
lines changed

completions/_udevadm

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ _comp_cmd_udevadm()
3434
return
3535
;;
3636
--name)
37-
: "${cur:=/dev/}"
38-
_comp_compgen filedir
37+
_comp_compgen -c "${cur:-/dev/}" filedir
3938
return
4039
;;
4140
--device-id-of-file | --exit-if-exists)

completions/badblocks

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ _comp_cmd_badblocks()
2121
return
2222
fi
2323

24-
: "${cur:=/dev/}"
25-
_comp_compgen filedir
24+
_comp_compgen -c "${cur:-/dev/}" filedir
2625
} &&
2726
complete -F _comp_cmd_badblocks badblocks
2827

completions/cryptsetup

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ _comp_cmd_cryptsetup__name()
77

88
_comp_cmd_cryptsetup__device()
99
{
10-
: "${cur:=/dev/}"
11-
_comp_compgen filedir
10+
_comp_compgen -c "${cur:-/dev/}" filedir
1211
}
1312

1413
_comp_cmd_cryptsetup()

completions/curl

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ _comp_cmd_curl()
5353
--data | --data-ascii | --data-binary | --data-urlencode | --header | \
5454
--proxy-header | -${noargopts}[dH])
5555
if [[ $cur == \@* ]]; then
56-
cur=${cur:1}
57-
_comp_compgen filedir
56+
_comp_compgen -c "${cur:1}" filedir
5857
if [[ ${#COMPREPLY[@]} -eq 1 && -d ${COMPREPLY[0]} ]]; then
5958
COMPREPLY[0]+=/
6059
compopt -o nospace

completions/dd

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ _comp_cmd_dd()
77

88
case $cur in
99
if=* | of=*)
10-
cur=${cur#*=}
11-
_comp_compgen filedir
10+
_comp_compgen -c "${cur#*=}" filedir
1211
return
1312
;;
1413
conv=*)

completions/dnssec-keygen

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ _comp_cmd_dnssec_keygen()
2727
return
2828
;;
2929
-r)
30-
: "${cur:=/dev/}"
31-
_comp_compgen filedir
30+
_comp_compgen -c "${cur:-/dev/}" filedir
3231
return
3332
;;
3433
-v)

completions/dot

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ _comp_cmd_dot()
2626
return
2727
;;
2828
-o*)
29-
cur=${cur#-o}
30-
_comp_compgen filedir
31-
((${#COMPREPLY[@]})) &&
32-
COMPREPLY=($(compgen -P -o -W '"${COMPREPLY[@]}"' -- "$cur"))
29+
_comp_compgen -c "${cur#-o}" filedir
30+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-o}")
3331
return
3432
;;
3533
esac

completions/dumpe2fs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ _comp_cmd_dumpe2fs()
2020
return
2121
fi
2222

23-
: "${cur:=/dev/}"
24-
_comp_compgen filedir
23+
_comp_compgen -c "${cur:-/dev/}" filedir
2524
} &&
2625
complete -F _comp_cmd_dumpe2fs dumpe2fs
2726

completions/e2freefrag

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ _comp_cmd_e2freefrag()
1616
return
1717
fi
1818

19-
: "${cur:=/dev/}"
20-
_comp_compgen filedir
19+
_comp_compgen -c "${cur:-/dev/}" filedir
2120
} &&
2221
complete -F _comp_cmd_e2freefrag e2freefrag
2322

completions/e2label

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ _comp_cmd_e2label()
66
_comp_initialize -- "$@" || return
77

88
if ((cword == 1)); then
9-
: "${cur:=/dev/}"
10-
_comp_compgen filedir
9+
_comp_compgen -c "${cur:-/dev/}" filedir
1110
fi
1211
} &&
1312
complete -F _comp_cmd_e2label e2label

completions/export

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ _comp_cmd_export()
3838
if [[ $pval != \'\' ]]; then
3939
COMPREPLY=("$pval")
4040
else
41-
cur=${cur#*=}
42-
_comp_compgen filedir
41+
_comp_compgen -c "${cur#*=}" filedir
4342
fi
4443
;;
4544
*=*)
46-
cur=${cur#*=}
47-
_comp_compgen filedir
45+
_comp_compgen -c "${cur#*=}" filedir
4846
;;
4947
*)
5048
if [[ $cword -eq 1 && $cur == -* ]]; then

completions/gprof

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ _comp_cmd_gprof()
1010
return
1111
;;
1212
-S*)
13-
cur=${cur:2}
14-
_comp_compgen filedir
15-
COMPREPLY=("${COMPREPLY[@]/#/-S}")
13+
_comp_compgen -c "${cur:2}" filedir
14+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-S}")
1615
return
1716
;;
1817
-O*)

completions/growisofs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ _comp_cmd_growisofs()
1717
/?(r)dev/*)
1818
if [[ $cur == =* ]]; then
1919
# e.g. /dev/dvd=foo.iso, /dev/dvdrw=/dev/zero
20-
cur="${cur#=}"
21-
_comp_compgen filedir
20+
_comp_compgen -c "${cur#=}" filedir
2221
return
2322
fi
2423
;;

completions/hddtemp

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ _comp_cmd_hddtemp()
3131
COMPREPLY=($(compgen -W '$(_parse_help "$1") --help' -- "$cur"))
3232
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
3333
else
34-
: "${cur:=/dev/}"
35-
_comp_compgen filedir
34+
_comp_compgen -c "${cur:-/dev/}" filedir
3635
fi
3736
} &&
3837
complete -F _comp_cmd_hddtemp hddtemp

completions/java

+5-10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# available path elements completion
44
_comp_cmd_java__classpath()
55
{
6-
cur=${cur##*:}
7-
_comp_compgen filedir '@(jar|zip)'
6+
_comp_compgen -c "${cur##*:}" filedir '@(jar|zip)'
87
}
98

109
# exact classpath determination
@@ -165,19 +164,16 @@ _comp_cmd_java()
165164
return
166165
;;
167166
-javaagent:*)
168-
cur=${cur#*:}
169-
_comp_compgen filedir '@(jar|zip)'
167+
_comp_compgen -c "${cur#*:}" filedir '@(jar|zip)'
170168
return
171169
;;
172170
-agentpath:*)
173-
cur=${cur#*:}
174-
_comp_compgen filedir so
171+
_comp_compgen -c "${cur#*:}" filedir so
175172
return
176173
;;
177174
# various non-standard option completions
178175
-splash:*)
179-
cur=${cur#*:}
180-
_comp_compgen filedir '@(gif|jp?(e)g|png)'
176+
_comp_compgen -c "${cur#*:}" filedir '@(gif|jp?(e)g|png)'
181177
return
182178
;;
183179
-Xbootclasspath*:*)
@@ -199,8 +195,7 @@ _comp_cmd_java()
199195
return
200196
;;
201197
-Xloggc:* | -Xverboselog:*)
202-
cur=${cur#*:}
203-
_comp_compgen filedir
198+
_comp_compgen -c "${cur#*:}" filedir
204199
return
205200
;;
206201
-Xshare:*)

completions/kcov

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ _comp_cmd_kcov()
2121
;;
2222
--replace-src-path)
2323
if [[ $cur == ?*:* ]]; then
24-
cur="${cur##*:}"
25-
_comp_compgen filedir
24+
_comp_compgen -c "${cur##*:}" filedir
2625
else
2726
_comp_compgen filedir
2827
compopt -o nospace

completions/lilo

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ _comp_cmd_lilo()
3535
;;
3636
-A | -b | -M | -u | -U)
3737
# device completion
38-
: "${cur:=/dev/}"
39-
_comp_compgen filedir
38+
_comp_compgen -c "${cur:-/dev/}" filedir
4039
return
4140
;;
4241
-T)

completions/lvm

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
_comp_cmd_lvm__filedir()
44
{
5-
: "${cur:=/dev/}"
6-
_comp_compgen filedir
5+
_comp_compgen -c "${cur:-/dev/}" filedir
76
}
87

98
_comp_cmd_lvm__volumegroups()

completions/mdadm

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ _comp_cmd_mdadm()
145145
fi
146146
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
147147
else
148-
: "${cur:=/dev/}"
149-
_comp_compgen filedir
148+
_comp_compgen -c "${cur:-/dev/}" filedir
150149
fi
151150
} &&
152151
complete -F _comp_cmd_mdadm mdadm

completions/mplayer

+1-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ _comp_cmd_mplayer()
110110
return
111111
;;
112112
-mixer | -dvdauth | -fb | -zrdev)
113-
: "${cur:=/dev/}"
114-
_comp_compgen filedir
113+
_comp_compgen -c "${cur:-/dev/}" filedir
115114
return
116115
;;
117116
-edl | -edlout | -lircconf | -menu-cfg | -playlist | -csslib | -dumpfile | \

completions/mutt

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ _comp_cmd_mutt__filedir()
149149
command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')"
150150
[[ $spoolfile ]] && eval cur="${cur/^!/$spoolfile}"
151151
fi
152-
_comp_compgen filedir
152+
_comp_compgen -c "$cur" filedir
153153
}
154154

155155
_comp_cmd_mutt()

completions/nsupdate

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ _comp_cmd_nsupdate()
1414
return
1515
;;
1616
-*R)
17-
: "${cur:=/dev/}"
18-
_comp_compgen filedir
17+
_comp_compgen -c "${cur:-/dev/}" filedir
1918
return
2019
;;
2120
-*y)

completions/perltidy

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ _comp_cmd_perltidy()
1717

1818
case $cur in
1919
-pro=* | --profile=*)
20-
cur="${cur#*=}"
21-
_comp_compgen filedir
20+
_comp_compgen -c "${cur#*=}" filedir
2221
return
2322
;;
2423
-ole=* | --output-line-ending=*)

completions/povray

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _comp_cmd_povray()
1616
cur="${povcur#[-+]I}" # to confuse _comp_compgen_filedir
1717
pfx="${povcur%"$cur"}"
1818
_comp_compgen filedir pov
19-
COMPREPLY=(${COMPREPLY[@]/#/$pfx})
19+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/$pfx}")
2020
return
2121
;;
2222
[-+]O*)
@@ -40,7 +40,7 @@ _comp_cmd_povray()
4040
cur="${povcur#[-+]O}" # to confuse _comp_compgen_filedir
4141
pfx="${povcur%"$cur"}"
4242
_comp_compgen -a filedir $oext
43-
COMPREPLY=(${COMPREPLY[@]/#/$pfx})
43+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/$pfx}")
4444
return
4545
;;
4646
*.ini\[ | *.ini\[*[^]]) # sections in .ini files
@@ -52,7 +52,7 @@ _comp_cmd_povray()
5252
-e 't' -e 'd' -- "$pfx"
5353
))
5454
# to prevent [bar] expand to nothing. can be done more easily?
55-
COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}")
55+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}")
5656
return
5757
;;
5858
*)

completions/protoc

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ _comp_cmd_protoc()
3434

3535
case $cur in
3636
-o*)
37-
cur=${cur:2}
38-
_comp_compgen filedir
39-
COMPREPLY=("${COMPREPLY[@]/#/-o}")
37+
_comp_compgen -c "${cur:2}" filedir
38+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-o}")
4039
return
4140
;;
4241
-I*)
43-
cur=${cur:2}
44-
_comp_compgen filedir -d
45-
COMPREPLY=("${COMPREPLY[@]/#/-I}")
42+
_comp_compgen -c "${cur:2}" filedir -d
43+
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-I}")
4644
return
4745
;;
4846
-*)

completions/smartctl

+1-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ _comp_cmd_smartctl()
124124
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
125125
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
126126
else
127-
: "${cur:=/dev/}"
128-
_comp_compgen filedir
127+
_comp_compgen -c "${cur:-/dev/}" filedir
129128
fi
130129
} &&
131130
complete -F _comp_cmd_smartctl smartctl

completions/ssh

+2-6
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,9 @@ _comp_cmd_ssh()
341341
esac
342342

343343
if [[ $cur == -F* ]]; then
344-
cur=${cur#-F}
345-
_comp_compgen filedir
344+
_comp_compgen -c "${cur#-F}" filedir
346345
# Prefix completions with '-F'
347346
COMPREPLY=("${COMPREPLY[@]/#/-F}")
348-
cur=-F$cur # Restore cur
349347
elif [[ $cur == -* ]]; then
350348
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
351349
else
@@ -416,11 +414,9 @@ _comp_cmd_sftp()
416414
esac
417415

418416
if [[ $cur == -F* ]]; then
419-
cur=${cur#-F}
420-
_comp_compgen filedir
417+
_comp_compgen -c "${cur#-F}" filedir
421418
# Prefix completions with '-F'
422419
COMPREPLY=("${COMPREPLY[@]/#/-F}")
423-
cur=-F$cur # Restore cur
424420
elif [[ $cur == -* ]]; then
425421
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
426422
else

completions/ssh-keygen

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ _comp_cmd_ssh_keygen()
8282
COMPREPLY=($(compgen -c -- "${cur#*=}"))
8383
;;
8484
checkpoint=* | challenge=* | write-attestation=*)
85-
cur=${cur#*=}
86-
_comp_compgen filedir
85+
_comp_compgen -c "${cur#*=}" filedir
8786
;;
8887
application=*([^:=]))
8988
COMPREPLY=($(compgen -W "ssh:" -- "${cur#*=}"))

0 commit comments

Comments
 (0)