Skip to content

Commit 810d454

Browse files
authored
Merge pull request #956 from akinomyoga/_comp_compgen-0
fix: add misc fixes before `_comp_compgen` changes
2 parents 72a8c48 + e41e3b5 commit 810d454

File tree

19 files changed

+44
-38
lines changed

19 files changed

+44
-38
lines changed

completions/aclocal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _comp_cmd_aclocal()
2020
--warnings | -W)
2121
local cats=(syntax unsupported)
2222
COMPREPLY=($(compgen -W \
23-
'${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
23+
'"${cats[@]}" "${cats[@]/#/no-}" all none error' -- "$cur"))
2424
return
2525
;;
2626
esac

completions/autoconf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _comp_cmd_autoconf()
1616
--warnings | -W)
1717
local cats=(cross obsolete syntax)
1818
COMPREPLY=($(compgen -W \
19-
'${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
19+
'"${cats[@]}" "${cats[@]/#/no-}" all none error' -- "$cur"))
2020
return
2121
;;
2222
--prepend-include | -B | --include | -I)

completions/automake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ _comp_cmd_automake()
1212
--warnings | -W)
1313
local cats=(gnu obsolete override portability syntax unsupported)
1414
COMPREPLY=($(compgen -W \
15-
'${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
15+
'"${cats[@]}" "${cats[@]/#/no-}" all none error' -- "$cur"))
1616
return
1717
;;
1818
--libdir)

completions/autoreconf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _comp_cmd_autoreconf()
1313
local cats=(cross gnu obsolete override portability syntax
1414
unsupported)
1515
COMPREPLY=($(compgen -W \
16-
'${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
16+
'"${cats[@]}" "${cats[@]/#/no-}" all none error' -- "$cur"))
1717
return
1818
;;
1919
--prepend-include | -B | --include | -I)

completions/carton

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _comp_cmd_carton__commands()
44
{
55
local cmds=$("${1:-carton}" usage 2>&1 |
66
command sed -ne '/.*command.* is one of/{n;p;q;}')
7-
COMPREPLY+=($(IFS="$IFS," compgen -W "$cmds" -- "$cur"))
7+
COMPREPLY+=($(IFS=$' \t\n,' compgen -W "$cmds" -- "$cur"))
88
}
99

1010
_comp_cmd_carton__command_help()

completions/cd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ _comp_cmd_cd()
3030
_comp_readline_variable_on mark-symlinked-directories && mark_symdirs=y
3131

3232
# we have a CDPATH, so loop on its contents
33-
for i in ${CDPATH//:/$'\n'}; do
33+
local paths dirs
34+
_comp_split -F : paths "$CDPATH"
35+
for i in "${paths[@]}"; do
3436
# create an array of matched subdirs
3537
k=${#COMPREPLY[@]}
36-
for j in $(compgen -d -- "$i/$cur"); do
38+
_comp_compgen -v dirs -c "$i/$cur" -- -d
39+
for j in "${dirs[@]}"; do
3740
if [[ ($mark_symdirs && -L $j || $mark_dirs && ! -L $j) && ! -d ${j#"$i/"} ]]; then
3841
j+="/"
3942
fi

completions/dict

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ _comp_cmd_dict()
5858
# in a pattern instead.
5959
if [[ $cur == +([-A-Za-z0-9/.]) ]]; then
6060
COMPREPLY=($(compgen -W \
61-
'$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur"))
61+
'$(command grep "^${cur//./\\.}" "$dictfile")' -- "$cur"))
6262
else
63-
COMPREPLY=($(compgen -W '$(cat $dictfile)' -- "$cur"))
63+
COMPREPLY=($(compgen -W '$(cat "$dictfile")' -- "$cur"))
6464
fi
6565
fi
6666
} &&

completions/ebtables

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,39 @@ _comp_cmd_ebtables()
55
local cur prev words cword was_split comp_args
66
_comp_initialize -s -- "$@" || return
77

8-
local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
8+
local table="" chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
99
targets='ACCEPT DROP CONTINUE RETURN'
1010

11+
local IFS=$' \t\n' # for ${table:+-t "$table"}
1112
[[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
12-
table="-t ${BASH_REMATCH[2]}"
13+
table=${BASH_REMATCH[2]}
1314

1415
local noargopts='!(-*|*[AIDPFXLZtj]*)'
1516
# shellcheck disable=SC2254
1617
case $prev in
1718
-${noargopts}[AIDPFXLZ])
18-
COMPREPLY=($(compgen -W '`"$1" $table -L 2>/dev/null | \
19+
COMPREPLY=($(compgen -W '`"$1" ${table:+-t "$table"} -L 2>/dev/null | \
1920
command sed -ne "$chain"`' -- "$cur"))
2021
;;
2122
-${noargopts}t)
2223
COMPREPLY=($(compgen -W 'nat filter broute' -- "$cur"))
2324
;;
2425
-${noargopts}j)
25-
if [[ $table == "-t filter" || ! $table ]]; then
26+
if [[ $table == "filter" || ! $table ]]; then
2627
COMPREPLY=($(compgen -W '$targets
27-
$("$1" $table -L 2>/dev/null | \
28+
$("$1" ${table:+-t "$table"} -L 2>/dev/null | \
2829
command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \
2930
-e "$chain")' \
3031
-- "$cur"))
31-
elif [[ $table == "-t nat" ]]; then
32+
elif [[ $table == "nat" ]]; then
3233
COMPREPLY=($(compgen -W '$targets
33-
$("$1" $table -L 2>/dev/null | \
34+
$("$1" -t "$table" -L 2>/dev/null | \
3435
command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \
3536
-e "$chain")' \
3637
-- "$cur"))
37-
elif [[ $table == "-t broute" ]]; then
38+
elif [[ $table == "broute" ]]; then
3839
COMPREPLY=($(compgen -W 'ACCEPT DROP
39-
$("$1" $table -L 2>/dev/null | \
40+
$("$1" -t "$table" -L 2>/dev/null | \
4041
command sed -n -e "s/BROUTING//" -e "$chain")' \
4142
-- "$cur"))
4243
fi

completions/gssdp-discover

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ _comp_cmd_gssdp_discover()
1818
local types=$("$1" --help 2>&1 |
1919
command sed -ne 's/^.*--message-type=.*(\([^)]*\))$/\1/p')
2020
COMPREPLY=($(
21-
IFS+=,
21+
IFS=$' \t\n,'
2222
compgen -W "$types" -- "$cur"
2323
))
2424
return

completions/influx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _comp_cmd_influx()
1616
-format | -precision | -consistency)
1717
local args=$("$1" --help 2>&1 | awk "\$1 == \"$prev\" { print \$2 }")
1818
COMPREPLY=($(
19-
IFS+="\"'|"
19+
IFS=$' \t\n'"\"'|"
2020
compgen -W "$args" -- "$cur"
2121
))
2222
return

0 commit comments

Comments
 (0)