Skip to content

Commit e97f4a6

Browse files
committed
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 <[email protected]>
1 parent 7f9f230 commit e97f4a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/test-lib-functions.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ test_commit () {
385385
shift
386386
done &&
387387
indir=${indir:+"$indir"/} &&
388-
local file=${2:-"$1.t"} &&
388+
local file="${2:-"$1.t"}" &&
389389
if test -n "$append"
390390
then
391391
$echo "${3-$1}" >>"$indir$file"
@@ -1748,7 +1748,7 @@ test_oid () {
17481748
# Insert a slash into an object ID so it can be used to reference a location
17491749
# under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..".
17501750
test_oid_to_path () {
1751-
local basename=${1#??}
1751+
local basename="${1#??}"
17521752
echo "${1%$basename}/$basename"
17531753
}
17541754

@@ -1930,7 +1930,7 @@ test_readlink () {
19301930
# An optional increment to the magic timestamp may be specified as second
19311931
# argument.
19321932
test_set_magic_mtime () {
1933-
local inc=${2:-0} &&
1933+
local inc="${2:-0}" &&
19341934
local mtime=$((1234567890 + $inc)) &&
19351935
test-tool chmtime =$mtime "$1" &&
19361936
test_is_magic_mtime "$1" $inc
@@ -1943,7 +1943,7 @@ test_set_magic_mtime () {
19431943
# argument. Usually, this should be the same increment which was used for
19441944
# the associated test_set_magic_mtime.
19451945
test_is_magic_mtime () {
1946-
local inc=${2:-0} &&
1946+
local inc="${2:-0}" &&
19471947
local mtime=$((1234567890 + $inc)) &&
19481948
echo $mtime >.git/test-mtime-expect &&
19491949
test-tool chmtime --get "$1" >.git/test-mtime-actual &&

0 commit comments

Comments
 (0)