git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] tests: fix non-portable "${var:-"str"}" construct

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 28, 2018, 19:38 UTC
Message-ID
<20180828193827.8648-2-avarab@gmail.com>
In-Reply-To
<20180828193827.8648-1-avarab@gmail.com>

On both AIX 7200-00-01-1543 and FreeBSD 11.2-RELEASE-p2 the "${var:-"str"}" syntax means something different than what it does under the bash or dash shells.

Both will consider the start of the new unescaped quotes to be a new argument to test_expect_success, resulting in the following error:

    error: bug in the test script: 'git diff-tree initial # magic
    is (not' does not look like a prereq

Fix this by removing the redundant quotes. There's no need for them, and the resulting code works under all the aforementioned shells. This fixes a regression in c2f1d3989 ("t4013: test new output from diff --abbrev --raw", 2017-12-03) first released with Git v2.16.0.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4013-diff-various.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index f8d853595b..73f7038253 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -140,7 +140,7 @@ do
 	expect="$TEST_DIRECTORY/t4013/diff.$test"
 	actual="$pfx-diff.$test"
 
-	test_expect_success "git $cmd # magic is ${magic:-"(not used)"}" '
+	test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
 		{
 			echo "$ git $cmd"
 			case "$magic" in
-- 
2.19.0.rc0.228.g281dcd1b4d0
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 2 of 6 in “FreeBSD & AIX test portability fixes”
  1. 0/2 FreeBSD & AIX test portability fixesÆvar Arnfjörð Bjarmason, Aug 28, 2018
  2. 1/2 tests: fix non-portable "${var:-"str"}" constructÆvar Arnfjörð Bjarmason, Aug 28, 2018
  3. Junio C HamanoAug 28, 2018
  4. Ann T RopeaAug 29, 2018
  5. 2/2 tests: fix non-portable iconv invocationÆvar Arnfjörð Bjarmason, Aug 28, 2018
  6. Jonathan NiederAug 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.