Skip to content

Commit 8a996ed

Browse files
committed
test: Fix failing tests on Bash 4.3
Bash does not support '@' when introspecting variables. Provide a fallback
1 parent 6b631a9 commit 8a996ed

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

tests/util/test_util.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
test_util.is_exported() {
55
local variable_name="$1"
66

7-
local -n variable="$variable_name"
8-
if [[ "${variable@a}" == *x* ]]; then
9-
return 0
7+
if (( BASH_VERSINFO[0] > 4 )) || (( BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4 )); then
8+
local -n variable="$variable_name"
9+
if [[ "${variable@a}" == *x* ]]; then
10+
return 0
11+
else
12+
return 1
13+
fi
1014
else
11-
return 1
15+
if declare -x | while read -r line; do
16+
case "$line" in
17+
"declare -x $variable_name"=*) return 10 ;;
18+
esac
19+
done; then
20+
return 1
21+
else
22+
if (($? == 10)); then
23+
return 0
24+
else
25+
return 1
26+
fi
27+
fi
1228
fi
1329
}
1430

0 commit comments

Comments
 (0)