Skip to content

Commit b280f3b

Browse files
committed
test: Improve is_exported function
1 parent 8a996ed commit b280f3b

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

tests/util/test_util.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,28 @@ test_util.is_exported() {
1212
return 1
1313
fi
1414
else
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
15+
local output=
16+
output="$(declare -p "$variable_name")"
17+
18+
case "$output" in
19+
"declare -x $variable_name"=*) return 0 ;;
20+
esac
21+
22+
return 1
23+
24+
# if declare -x | while read -r line; do
25+
# case "$line" in
26+
# "declare -x $variable_name"=*) return 10 ;;
27+
# esac
28+
# done; then
29+
# return 1
30+
# else
31+
# if (($? == 10)); then
32+
# return 0
33+
# else
34+
# return 1
35+
# fi
36+
# fi
2837
fi
2938
}
3039

0 commit comments

Comments
 (0)