Skip to content

Commit 341aad8

Browse files
committed
t: local VAR="VAL" (quote positional parameters)
Future-proof test scripts that do local VAR=VAL without quoting VAL (which is OK in POSIX but broken in some shells) that is a positional parameter, e.g. $4. Signed-off-by: Junio C Hamano <[email protected]>
1 parent be34b51 commit 341aad8

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

t/lib-parallel-checkout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_checkout_workers () {
2020
BUG "too few arguments to test_checkout_workers"
2121
fi &&
2222

23-
local expected_workers=$1 &&
23+
local expected_workers="$1" &&
2424
shift &&
2525

2626
local trace_file=trace-test-checkout-workers &&

t/t2400-worktree-add.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ test_expect_success '"add" worktree with orphan branch, lock, and reason' '
427427
# Note: Quoted arguments containing spaces are not supported.
428428
test_wt_add_orphan_hint () {
429429
local context="$1" &&
430-
local use_branch=$2 &&
430+
local use_branch="$2" &&
431431
shift 2 &&
432432
local opts="$*" &&
433433
test_expect_success "'worktree add' show orphan hint in bad/orphan HEAD w/ $context" '

t/t4210-log-i18n.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test_expect_success 'log --grep does not find non-reencoded values (latin1)' '
6464
'
6565

6666
triggers_undefined_behaviour () {
67-
local engine=$1
67+
local engine="$1"
6868

6969
case $engine in
7070
fixed)
@@ -85,7 +85,7 @@ triggers_undefined_behaviour () {
8585
}
8686

8787
mismatched_git_log () {
88-
local pattern=$1
88+
local pattern="$1"
8989

9090
LC_ALL=$is_IS_locale git log --encoding=ISO-8859-1 --format=%s \
9191
--grep=$pattern

t/test-lib-functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ test_parse_ls_tree_oids () {
17651765
# Choose a port number based on the test script's number and store it in
17661766
# the given variable name, unless that variable already contains a number.
17671767
test_set_port () {
1768-
local var=$1 port
1768+
local var="$1" port
17691769

17701770
if test $# -ne 1 || test -z "$var"
17711771
then

0 commit comments

Comments
 (0)