[PATCH] filter-branch: use $(($i+1)) instead of $((i+1))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The expression $((i+1)) is not portable at all: even some bash versions
do not grok it. So do not use it.

Noticed by Jonas Fonseca.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	On Tue, 5 Jun 2007, Jonas Fonseca wrote:
	
	> Junio C Hamano <gitster@xxxxxxxxx> wrote Tue, Jun 05, 2007:
	> > Jonas Fonseca <fonseca@xxxxxxx> writes:
	> > 
	> > > $ git filter-branch H2
	> > > /home/fonseca/bin/git-filter-branch: 386: arith: syntax error: "i+1"
	> > > $
	> > >
	> > > A possible fix that makes the test pass for me.
	> >
	> > [...]
	> >
	> > The portable ones we already have in the code say things like:
	> > 
	> > 	msgnum=$(($msgnum+1))
	> 
	> Yes, I should have investigated before sending.
	> 
	> > The one in filter-branch that bit you does not dereference 'i'.
	> > I am reasonably sure if you fix it to read:
	> > 
	> > 	i=$(( $i+1 ))
	> > 
	> > dash would grok it.
	> 
	> This works here. Even without the spaces.

	Voila.

 git-filter-branch.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 6807782..f89cfe1 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -334,7 +334,7 @@ test $commits -eq 0 && die "Found nothing to rewrite"
 
 i=0
 while read commit; do
-	i=$((i+1))
+	i=$(($i+1))
 	printf "$commit ($i/$commits) "
 
 	git-read-tree -i -m $commit
-- 
1.5.2.1.2656.g1921f

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux