Skip to contentSkip to conversation

t3419-*.sh: Fix arithmetic expansion syntax error

PATCH In review Ramsay Jones 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t3419-*.sh: Fix arithmetic expansion syntax error

Some shells, for example dash versions older than 0.5.4, need to spell a variable reference as '$N' rather than 'N' in an arithmetic expansion. In order to avoid the syntax error, we change the offending variable reference from 'i' to '$i' in function scramble.

---

Note that this test is unique in having an '#!/bin/bash' line (rather than '#!/bin/sh'), which was (indirectly) responsible for me not noticing this failure for a while. I don't see anything that would require bash, so I suspect this is not intensional.

ATB,
Ramsay Jones

 t/t3419-rebase-patch-id.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
t/t3419-rebase-patch-id.sh +1 -1
index 1aee483..6972b49 100755
@@ -27,7 +27,7 @@ scramble()
 		then
 			echo "$x"
 		fi
-		i=$(((i+1) % 10))
+		i=$((($i+1) % 10))
 	done < "$1" > "$1.new"
 	mv -f "$1.new" "$1"
 }
Signature · 1 line
1.7.3
#1 lore raw
Quoted 2 lines · Ramsay Jones

Thanks.

Quoted 4 lines

Note that this test is unique in having an '#!/bin/bash' line (rather than '#!/bin/sh'), which was (indirectly) responsible for me not noticing this failure for a while. I don't see anything that would require bash, so I suspect this is not intensional.

Indeed. I actually removed all bashisms from the script, but then apparently forgot to get rid of #!/bin/bash as well.

Clemens

#2 lore raw
In reply to Ramsay Jones
Quoted 2 lines · Ramsay Jones

Note that this test is unique in having an '#!/bin/bash' line (rather than '#!/bin/sh'),...

Thanks for spotting, and that is idiotic for us to have such a script. We should fix the shebang line as well.

A quick git-grep shows that this is the only instance of this problem (outside contrib/completion/git-completion.bash, that is).