Skip to content

Commit 969de74

Browse files
committed
Double quote to prevent globbing and word splitting
1 parent 631a8e5 commit 969de74

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bash_unit

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ run_test_suite() {
149149
run_test() {
150150
set -e
151151
notify_test_starting "$__bash_unit_current_test__"
152-
$__bash_unit_current_test__ && notify_test_succeeded "$__bash_unit_current_test__"
152+
"$__bash_unit_current_test__" && notify_test_succeeded "$__bash_unit_current_test__"
153153
}
154154

155155
usage() {
@@ -222,10 +222,10 @@ text_format() {
222222
[[ -z $message ]] || printf -- "$message\n"
223223
}
224224
notify_stdout() {
225-
sed 's:^:out> :' | color $GREEN
225+
sed 's:^:out> :' | color "$GREEN"
226226
}
227227
notify_stderr() {
228-
sed 's:^:err> :' | color $RED
228+
sed 's:^:err> :' | color "$RED"
229229
}
230230
notify_stack() {
231231
color "$YELLOW"
@@ -253,10 +253,10 @@ tap_format() {
253253
[[ -z $message ]] || printf -- "$message\n" | sed -u -e 's/^/# /'
254254
}
255255
notify_stdout() {
256-
sed 's:^:# out> :' | color $GREEN
256+
sed 's:^:# out> :' | color "$GREEN"
257257
}
258258
notify_stderr() {
259-
sed 's:^:# err> :' | color $RED
259+
sed 's:^:# err> :' | color "$RED"
260260
}
261261
notify_stack() {
262262
sed 's:^:# :' | color "$YELLOW"
@@ -289,8 +289,8 @@ shift $((OPTIND-1))
289289

290290
for test_file in "$@"
291291
do
292-
test -e $test_file || usage "file does not exist: $test_file"
293-
test -r $test_file || usage "can not read file: $test_file"
292+
test -e "$test_file" || usage "file does not exist: $test_file"
293+
test -r "$test_file" || usage "can not read file: $test_file"
294294
done
295295

296296
case "$output_format" in
@@ -312,7 +312,7 @@ do
312312
notify_suite_starting "$test_file"
313313
(
314314
source "$test_file"
315-
cd $(dirname "$test_file")
315+
cd "$(dirname "$test_file")"
316316
run_test_suite
317317
)
318318
failure=$(( $? || failure))

0 commit comments

Comments
 (0)