]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: local VAR="VAL" (quote command substitution)
authorJunio C Hamano <gitster@pobox.com>
Sat, 6 Apr 2024 00:09:00 +0000 (17:09 -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 $(command substitution).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4011-diff-symlink.sh
t/test-lib-functions.sh

index d7a5f7ae780c0319514fd949dacac98cfe6ce23b..bc8ba887191fac4fd602fe5c2406f3e66a4becfa 100755 (executable)
@@ -13,13 +13,13 @@ TEST_PASSES_SANITIZE_LEAK=true
 
 # Print the short OID of a symlink with the given name.
 symlink_oid () {
-       local oid=$(printf "%s" "$1" | git hash-object --stdin) &&
+       local oid="$(printf "%s" "$1" | git hash-object --stdin)" &&
        git rev-parse --short "$oid"
 }
 
 # Print the short OID of the given file.
 short_oid () {
-       local oid=$(git hash-object "$1") &&
+       local oid="$(git hash-object "$1")" &&
        git rev-parse --short "$oid"
 }
 
index fc607084717a5084d6ad0f61bf6cab8f375bf7a3..4cc7d74f110808222d8e6cf39f82c849f4751006 100644 (file)
@@ -1840,7 +1840,7 @@ test_subcommand () {
                shift
        fi
 
-       local expr=$(printf '"%s",' "$@")
+       local expr="$(printf '"%s",' "$@")"
        expr="${expr%,}"
 
        if test -n "$negate"