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 <gitster@pobox.com>

Junio C Hamano committed Apr 5, 2024 at 17:08 UTC 341aad8d41ca8321d826e1ce012e4faf1a8be2a4
4 files changed +5 -5
t/lib-parallel-checkout.sh
+1 -1
@@ -20,7 +20,7 @@ test_checkout_workers () {
20 BUG "too few arguments to test_checkout_workers"
21 fi &&
22
23 - local expected_workers=$1 &&
23 + local expected_workers="$1" &&
24 shift &&
25
26 local trace_file=trace-test-checkout-workers &&
t/t2400-worktree-add.sh
+1 -1
@@ -427,7 +427,7 @@ test_expect_success '"add" worktree with orphan branch, lock, and reason' '
427 # Note: Quoted arguments containing spaces are not supported.
428 test_wt_add_orphan_hint () {
429 local context="$1" &&
430 - local use_branch=$2 &&
430 + local use_branch="$2" &&
431 shift 2 &&
432 local opts="$*" &&
433 test_expect_success "'worktree add' show orphan hint in bad/orphan HEAD w/ $context" '
t/t4210-log-i18n.sh
+2 -2
@@ -64,7 +64,7 @@ test_expect_success 'log --grep does not find non-reencoded values (latin1)' '
64 '
65
66 triggers_undefined_behaviour () {
67 - local engine=$1
67 + local engine="$1"
68
69 case $engine in
70 fixed)
@@ -85,7 +85,7 @@ triggers_undefined_behaviour () {
85 }
86
87 mismatched_git_log () {
88 - local pattern=$1
88 + local pattern="$1"
89
90 LC_ALL=$is_IS_locale git log --encoding=ISO-8859-1 --format=%s \
91 --grep=$pattern
t/test-lib-functions.sh
+1 -1
@@ -1765,7 +1765,7 @@ test_parse_ls_tree_oids () {
1765 # Choose a port number based on the test script's number and store it in
1766 # the given variable name, unless that variable already contains a number.
1767 test_set_port () {
1768 - local var=$1 port
1768 + local var="$1" port
1769
1770 if test $# -ne 1 || test -z "$var"
1771 then