t: local VAR="VAL" (quote ${magic-reference})

Future-proof test scripts that do local VAR=VAL without quoting VAL (which is OK in POSIX but broken in some shells) that is ${magic-"reference to a parameter"}. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 5, 2024 at 17:09 UTC e97f4a6d94103c43a08c864c6ab63e6086812998
1 file changed +4 -4
t/test-lib-functions.sh
+4 -4
@@ -385,7 +385,7 @@ test_commit () {
385 shift
386 done &&
387 indir=${indir:+"$indir"/} &&
388 - local file=${2:-"$1.t"} &&
388 + local file="${2:-"$1.t"}" &&
389 if test -n "$append"
390 then
391 $echo "${3-$1}" >>"$indir$file"
@@ -1748,7 +1748,7 @@ test_oid () {
1748 # Insert a slash into an object ID so it can be used to reference a location
1749 # under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..".
1750 test_oid_to_path () {
1751 - local basename=${1#??}
1751 + local basename="${1#??}"
1752 echo "${1%$basename}/$basename"
1753 }
1754
@@ -1930,7 +1930,7 @@ test_readlink () {
1930 # An optional increment to the magic timestamp may be specified as second
1931 # argument.
1932 test_set_magic_mtime () {
1933 - local inc=${2:-0} &&
1933 + local inc="${2:-0}" &&
1934 local mtime=$((1234567890 + $inc)) &&
1935 test-tool chmtime =$mtime "$1" &&
1936 test_is_magic_mtime "$1" $inc
@@ -1943,7 +1943,7 @@ test_set_magic_mtime () {
1943 # argument. Usually, this should be the same increment which was used for
1944 # the associated test_set_magic_mtime.
1945 test_is_magic_mtime () {
1946 - local inc=${2:-0} &&
1946 + local inc="${2:-0}" &&
1947 local mtime=$((1234567890 + $inc)) &&
1948 echo $mtime >.git/test-mtime-expect &&
1949 test-tool chmtime --get "$1" >.git/test-mtime-actual &&