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

[PATCH] t1503: Fix arithmetic expansion syntax error when using dash

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Sep 21, 2010, 17:45 UTC
Message-ID
<4C98EF25.4070700@ramsay1.demon.co.uk>

On systems which have dash as /bin/sh, such as Ubuntu, the final test (master@{n} for various n) fails with a syntax error while processing an arithmetic expansion. The syntax error is caused by using a bare name ('N') as a variable reference in the expression.

In order to avoid the syntax error, we spell the variable reference as '$N' rather than simply 'N'.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 t/t1503-rev-parse-verify.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 100f857..813cc1b 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -106,8 +106,8 @@ test_expect_success 'use --default' '
 
 test_expect_success 'master@{n} for various n' '
 	N=$(git reflog | wc -l) &&
-	Nm1=$((N-1)) &&
-	Np1=$((N+1)) &&
+	Nm1=$(($N-1)) &&
+	Np1=$(($N+1)) &&
 	git rev-parse --verify master@{0} &&
 	git rev-parse --verify master@{1} &&
 	git rev-parse --verify master@{$Nm1} &&
-- 
1.7.3
Next: Junio C Hamano
Message 1 of 7 in “t1503: Fix arithmetic expansion syntax error when using dash”
  1. t1503: Fix arithmetic expansion syntax error when using dashRamsay Jones, Sep 21, 2010
  2. Re*: [PATCH] t1503: Fix arithmetic expansion syntax error when using dashJunio C Hamano, Sep 22, 2010
  3. Jon SeymourSep 22, 2010
  4. Ramsay JonesSep 25, 2010
  5. Ævar Arnfjörð BjarmasonSep 25, 2010
  6. Ramsay JonesSep 29, 2010
  7. Junio C HamanoSep 25, 2010

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.