Skip to content

Commit f966e62

Browse files
committed
fix(tree): work around bash-4.2 bug of [[ ${arr[*]} == *text* ]]
Bash 4.2 has a bug that the following test results in the exit status 1. $ a=(1 2 ''); [[ ${a[*]} == *\ 2\ * ]] To work around the problem caused by this behavior, in the `tree' completion, we store the value of ${words[*]} in a scalar local variable `line' and use it for the test.
1 parent 08dd2cd commit f966e62

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

completions/tree

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ _comp_cmd_tree()
3030
return
3131
fi
3232

33-
if [[ ${words[*]} == *\ --fromfile\ * ]]; then
33+
# Note: bash-4.2 has a bug with [[ ${arr[*]} == *text* ]], so we
34+
# assign ${words[*]} in a temporary variable "line".
35+
local line="${words[*]}"
36+
if [[ $line == *\ --fromfile\ * ]]; then
3437
_filedir
3538
else
3639
_filedir -d

0 commit comments

Comments
 (0)