]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: local VAR="VAL" (quote positional parameters)
authorJunio C Hamano <gitster@pobox.com>
Sat, 6 Apr 2024 00:08:59 +0000 (17:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Apr 2024 05:50:10 +0000 (22:50 -0700)
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>
t/lib-parallel-checkout.sh
t/t2400-worktree-add.sh
t/t4210-log-i18n.sh
t/test-lib-functions.sh

index acaee9cbb6ab9eb52d5b224ff71571b59fe5005b..8324d6c96dd058d5b732fbd222e098e5507329ff 100644 (file)
@@ -20,7 +20,7 @@ test_checkout_workers () {
                BUG "too few arguments to test_checkout_workers"
        fi &&
 
-       local expected_workers=$1 &&
+       local expected_workers="$1" &&
        shift &&
 
        local trace_file=trace-test-checkout-workers &&
index c28c04133c8a1c953406c5bdea0e83c8cb82870f..ba320dc4171aa7884591067c00853a955d84f4e8 100755 (executable)
@@ -427,7 +427,7 @@ test_expect_success '"add" worktree with orphan branch, lock, and reason' '
 # Note: Quoted arguments containing spaces are not supported.
 test_wt_add_orphan_hint () {
        local context="$1" &&
-       local use_branch=$2 &&
+       local use_branch="$2" &&
        shift 2 &&
        local opts="$*" &&
        test_expect_success "'worktree add' show orphan hint in bad/orphan HEAD w/ $context" '
index d2dfcf164e25b8771dd852d2aefc4aee4bd3f5ea..75216f19ce3a3e39e20b5d14406d9f1e8c34632b 100755 (executable)
@@ -64,7 +64,7 @@ test_expect_success 'log --grep does not find non-reencoded values (latin1)' '
 '
 
 triggers_undefined_behaviour () {
-       local engine=$1
+       local engine="$1"
 
        case $engine in
        fixed)
@@ -85,7 +85,7 @@ triggers_undefined_behaviour () {
 }
 
 mismatched_git_log () {
-       local pattern=$1
+       local pattern="$1"
 
        LC_ALL=$is_IS_locale git log --encoding=ISO-8859-1 --format=%s \
                --grep=$pattern
index 2eccf100c024e21363ac799a1d032470ede16ae9..fc607084717a5084d6ad0f61bf6cab8f375bf7a3 100644 (file)
@@ -1765,7 +1765,7 @@ test_parse_ls_tree_oids () {
 # Choose a port number based on the test script's number and store it in
 # the given variable name, unless that variable already contains a number.
 test_set_port () {
-       local var=$1 port
+       local var="$1" port
 
        if test $# -ne 1 || test -z "$var"
        then