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

[PATCH] git-submodule.sh: separate parens by a space to avoid confusing some shells

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
May 26, 2011, 20:52 UTC
Message-ID
<vWPtQ6mu-P8TxddTGAsNGMxxRy-vaOeaUiF8WZQpA2J8HcdAc02vCzYpygwdejLhR6OIWYLtPtK7E4oxXk50vg@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>

Some shells interpret '(( ))' according to the rules for arithmetic expansion. This may not follow POSIX, but is prevalent in commonly used shells. Bash does not have a problem with this particular instance of '((', likely because it is not followed by a '))', but the public domain ksh does, and so does ksh on IRIX 6.5.

So, add a space between the parenthesis to avoid confusing these shells.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index bf110e9..d189a24 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -495,7 +495,7 @@ cmd_update()
 				# Run fetch only if $sha1 isn't present or it
 				# is not reachable from a ref.
 				(clear_local_git_env; cd "$path" &&
-					((rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
+					( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
 					 test -z "$rev") || git-fetch)) ||
 				die "Unable to fetch in submodule path '$path'"
 			fi
-- 
1.7.4.4
Message 1 of 1 in “git-submodule.sh: separate parens by a space to avoid confusing some shells”
  1. git-submodule.sh: separate parens by a space to avoid confusing some shellsBrandon Casey, May 26, 2011

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.