Skip to content

Commit 6806708

Browse files
authored
Merge pull request #887 from akinomyoga/failglob-2
refactor(completions/*): ensure quoting for `compgen -W '${arr[@]}'`
2 parents a07e2a2 + 82042d2 commit 6806708

25 files changed

+51
-54
lines changed

bash_completion

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ _comp_delimited()
820820
fi
821821
done
822822
done
823-
COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "${cur##*"$delimiter"}"))
823+
((${#COMPREPLY[@]})) &&
824+
COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "${cur##*"$delimiter"}"))
824825
fi
825826
else
826827
COMPREPLY=($(compgen "$@" -- "${cur##*"$delimiter"}"))

completions/ccze

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _ccze()
2525
;;
2626
--option | -${noargopts}o)
2727
local -a opts=(scroll wordcolor lookups transparent cssfile)
28-
COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur"))
28+
COMPREPLY=($(compgen -W '"${opts[@]}" "${opts[@]/#/no}"' -- "$cur"))
2929
return
3030
;;
3131
--plugin | -${noargopts}p)

completions/complete

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ _complete()
4040
local -a opts=($(compgen -W '$(_parse_usage help "-s $1")' -- "$cur"))
4141
# -F, -C do not work the expected way with compgen
4242
[[ $1 != *compgen ]] || opts=("${opts[@]//-[FC]/}")
43-
COMPREPLY=($(compgen -W '${opts[@]}' -- "$cur"))
43+
COMPREPLY=($(compgen -W '"${opts[@]}"' -- "$cur"))
4444
else
4545
COMPREPLY=($(compgen -A command -- "$cur"))
4646
fi

completions/crontab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _crontab()
3636
done
3737

3838
if [[ $cur == -* ]]; then
39-
COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur"))
39+
COMPREPLY=($(compgen -W '"${!opts[@]}"' -- "$cur"))
4040
return
4141
fi
4242

completions/curl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ _curl()
113113
# Looks like an option? Likely no --help category support
114114
[[ $x != -* ]] || return
115115
done
116-
COMPREPLY=($(compgen -W '${categories[@]}' -- "$cur"))
116+
COMPREPLY=($(compgen -W '"${categories[@]}"' -- "$cur"))
117117
fi
118118
return
119119
;;

completions/cvs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ _comp_xfunc_cvs_roots()
4141
[[ -v CVSROOT ]] && cvsroots=("$CVSROOT")
4242
[[ -r ~/.cvspass ]] && cvsroots+=($(awk '{ print $2 }' ~/.cvspass))
4343
[[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots <CVS/Root
44-
COMPREPLY=($(compgen -W '${cvsroots[@]}' -- "$cur"))
44+
((${#cvsroots[@]})) &&
45+
COMPREPLY=($(compgen -W '"${cvsroots[@]}"' -- "$cur"))
4546
__ltrim_colon_completions "$cur"
4647
}
4748

completions/dpkg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ _comp_cmd_dpkg_reconfigure()
139139
--frontend | -${noargopts}f)
140140
_comp_expand_glob opt '/usr/share/perl5/Debconf/FrontEnd/*'
141141
if ((${#opt[@]})); then
142-
opt=(${opt[@]##*/})
143-
opt=(${opt[@]%.pm})
144-
COMPREPLY=($(compgen -W '${opt[@]}' -- "$cur"))
142+
opt=("${opt[@]##*/}")
143+
opt=("${opt[@]%.pm}")
144+
COMPREPLY=($(compgen -W '"${opt[@]}"' -- "$cur"))
145145
fi
146146
return
147147
;;

completions/hunspell

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _hunspell()
1616
dicts=("${dicts[@]##*/}")
1717
dicts=("${dicts[@]%.dic}")
1818
local IFS=$'\n'
19-
COMPREPLY=($(compgen -W '${dicts[@]}' -- "$cur"))
19+
COMPREPLY=($(compgen -W '"${dicts[@]}"' -- "$cur"))
2020
fi
2121
return
2222
;;

completions/ipmitool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ _ipmitool()
7676
done
7777

7878
if ! "$has_cmd"; then
79-
COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur"))
79+
COMPREPLY=($(compgen -W '"${cmds[@]}"' -- "$cur"))
8080
return
8181
fi
8282

completions/lintian

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
_lintian_tags()
44
{
5-
local match search tags check_files
5+
local search tags check_files
66
_comp_expand_glob check_files '/usr/share/lintian/checks/*.desc'
77
((${#check_files[@]})) || return 0
88

99
tags=$(awk '/^Tag/ { print $2 }' "${check_files[@]}")
1010
if [[ $cur == *, ]]; then
1111
search=${cur//,/ }
1212
for item in $search; do
13-
match=$(command grep -nE "^Tag: $item$" \
14-
"${check_files[@]}" | cut -d: -f1)
1513
tags=$(command sed -e "s/\<$item\>//g" <<<"$tags")
1614
done
1715
COMPREPLY+=($(compgen -W "$tags"))
@@ -50,7 +48,7 @@ _lintian_checks()
5048

5149
_lintian_infos()
5250
{
53-
local match search infos collection_files
51+
local search infos collection_files
5452
_comp_expand_glob collection_files '/usr/share/lintian/collection/*.desc'
5553
((${#collection_files[@]})) || return 0
5654

@@ -59,8 +57,6 @@ _lintian_infos()
5957
if [[ $cur == *, ]]; then
6058
search=${cur//,/ }
6159
for item in $search; do
62-
match=$(command grep -nE "^Collector: $item$" \
63-
"${collection_files[@]}" | cut -d: -f1)
6460
infos=$(command sed -e "s/\<$item\>//g" <<<"$infos")
6561
done
6662
COMPREPLY+=($(compgen -W "$infos"))

0 commit comments

Comments
 (0)