Skip to content

Commit 1fd456e

Browse files
akinomyogascop
authored andcommitted
fix(svcadm): fix ineffective IFS for splitting
Since IFS is specified, I guess this intends to split the content of $fmri by /. However, the word splitting does not happen because the entire word is quoted as `"$fmri"`. This quoting was introduced in commit 9ba5831 [1] to suppress shellcheck SC2086. In this patch, we split $fmri by `_comp_split`. [1] \ scop@9ba5831#diff-4e8aeaa79512c947f5558a112a1b5946b36604cef5229f622c05852d807c7947R48
1 parent 35a5eae commit 1fd456e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

completions/svcadm

+10-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ _comp_cmd_svcadm__fmri()
4444
# we generate all possibles abbreviations for the FMRI
4545
# no need to have a generic loop as we will have a finite
4646
# number of components
47-
local IFS="/"
48-
set -- "$fmri"
49-
_comp_unlocal IFS
50-
case $# in
51-
1) fmri_part_list=" $1" ;;
52-
2) fmri_part_list=" $2 $1/$2" ;;
53-
3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;;
54-
4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;;
55-
esac
47+
local -a tmp
48+
if _comp_split -F / tmp "$fmri"; then
49+
set -- "${tmp[@]}"
50+
case $# in
51+
1) fmri_part_list=" $1" ;;
52+
2) fmri_part_list=" $2 $1/$2" ;;
53+
3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;;
54+
4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;;
55+
esac
56+
fi
5657
else
5758
fmri_part_list="$fmri"
5859
fi

0 commit comments

Comments
 (0)