Skip to content

Commit b9609d9

Browse files
committed
refactor(completions/*): use _comp_split for arr=(...)
1 parent 246f6e2 commit b9609d9

File tree

9 files changed

+19
-24
lines changed

9 files changed

+19
-24
lines changed

completions/_adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _comp_cmd_adb()
3939
_comp_compgen -av tmp help -- help
4040
fi
4141
if [[ ! $cur || $cur != -* ]]; then
42-
tmp+=($("$1" help 2>&1 | _comp_awk '$1 == "adb" { print $2 }'))
42+
_comp_split -a tmp "$("$1" help 2>&1 | _comp_awk '$1 == "adb" { print $2 }')"
4343
tmp+=(devices connect disconnect sideload)
4444
fi
4545
((${#tmp[@]})) &&

completions/curl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ _comp_cmd_curl()
103103
return
104104
;;
105105
--help | -${noargopts}h)
106-
local x categories=(
107-
$("$1" --help non-existent-category 2>&1 |
108-
_comp_awk '/^[ \t]/ {print $1}')
109-
)
110-
if ((${#categories[@]})); then
106+
local x categories
107+
if _comp_split categories "$("$1" --help non-existent-category 2>&1 |
108+
_comp_awk '/^[ \t]/ {print $1}')"; then
111109
for x in "${categories[@]}"; do
112110
# Looks like an option? Likely no --help category support
113111
[[ $x != -* ]] || return

completions/cvs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _comp_xfunc_cvs_compgen_roots()
3838
{
3939
local -a cvsroots=()
4040
[[ -v CVSROOT ]] && cvsroots=("$CVSROOT")
41-
[[ -r ~/.cvspass ]] && cvsroots+=($(_comp_awk '{ print $2 }' ~/.cvspass))
41+
[[ -r ~/.cvspass ]] && _comp_split -a cvsroots "$(_comp_awk '{ print $2 }' ~/.cvspass)"
4242
[[ -r CVS/Root ]] && mapfile -tO "${#cvsroots[@]}" cvsroots <CVS/Root
4343
((${#cvsroots[@]})) &&
4444
_comp_compgen -U cvsroots -- -W '"${cvsroots[@]}"'

completions/fio

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ _comp_cmd_fio()
9898
return
9999
;;
100100
--?*)
101-
local IFS=$'\n'
102-
local cmdhelp=($("$1" --cmdhelp="${prev#--}" 2>/dev/null))
103-
_comp_unlocal IFS
101+
local -a cmdhelp
102+
_comp_split -l cmdhelp "$("$1" --cmdhelp="${prev#--}" 2>/dev/null)"
104103
case ${cmdhelp[*]-} in
105104
*"showing closest match"*)
106105
# ignore

completions/kldload

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ _comp_cmd_kldload()
1212
return
1313
fi
1414

15-
local moddirs modules i IFS=";"
16-
moddirs=($(kldconfig -r 2>/dev/null))
17-
_comp_unlocal IFS
18-
19-
if ((${#moddirs[@]})); then
15+
local moddirs modules i
16+
if _comp_split -F : moddirs "$(kldconfig -r 2>/dev/null)"; then
2017
compopt -o filenames
2118
for i in "${moddirs[@]}"; do
2219
_comp_compgen -v modules -c "$i/$cur" -- -f &&

completions/mplayer

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ _comp_cmd_mplayer()
5757
;;
5858
-subcp | -msgcharset)
5959
local cp
60-
cp=($(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null))
61-
if ((${#cp[@]})); then
60+
if _comp_split cp "$(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null)"; then
6261
if [[ $cur == "${cur,,}" ]]; then
6362
_comp_compgen -- -W '"${cp[@],,}"'
6463
else
@@ -80,7 +79,7 @@ _comp_cmd_mplayer()
8079
# may want to set the MPLAYER_SKINS_DIR global variable
8180
local -a dirs
8281
if [[ $MPLAYER_SKINS_DIR ]]; then
83-
dirs=($MPLAYER_SKINS_DIR)
82+
_comp_split dirs "$MPLAYER_SKINS_DIR"
8483
else
8584
dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins)
8685
fi

completions/mutt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ _comp_cmd_mutt__get_conffiles__visit()
6666
visited[$1]=set
6767
conffiles+=("$1")
6868

69-
local -a newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$1"))
70-
((${#newconffiles[@]})) || return 0
69+
local -a newconffiles
70+
_comp_split newconffiles "$(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$1")" ||
71+
return 0
7172

7273
local file REPLY
7374
for file in "${newconffiles[@]}"; do

completions/screen

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
_comp_cmd_screen__sessions()
44
{
5-
local sessions=($(command screen -ls | command sed -ne \
6-
's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p'))
7-
((${#sessions[@]} == 0)) && return
5+
local -a sessions
6+
_comp_split sessions "$(command screen -ls | command sed -ne \
7+
's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p')" || return
88
if [[ $cur == +([0-9])?(.*) ]]; then
99
# Complete sessions including pid prefixes
1010
_comp_compgen -- -W '"${sessions[@]}"'

completions/wget

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ _comp_cmd_wget()
5454
-W 'unix windows nocontrol ascii lowercase uppercase'
5555

5656
# +o nospace when no more valid option is possible (= append a space)
57-
local opt_as_arr=(${COMPREPLY[0]//,/ })
57+
local -a opt_as_arr
58+
_comp_split -F $', \t\n' opt_as_arr "${COMPREPLY[0]}"
5859
((${#opt_as_arr[@]} < 4)) && compopt -o nospace
5960
return
6061
;;

0 commit comments

Comments
 (0)