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

Re: [PATCH 3/5] Replace $((...)) with expr invocations.

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Nov 6, 2007, 20:18 UTC
Message-ID
<20071106201809.GD6361@ins.uni-bonn.de>
In-Reply-To
<20071106201518.GA6361@ins.uni-bonn.de>
---
 git-filter-branch.sh       |    4 ++--
 git-rebase--interactive.sh |    8 ++++----
 git-rebase.sh              |    8 ++++----
 3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ffcc408..2d5c247 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -253,7 +253,7 @@ test $commits -eq 0 && die "Found nothing to rewrite"
 
 i=0
 while read commit parents; do
-	i=$(($i+1))
+	i=$(expr $i + 1)
 	printf "\rRewrite $commit ($i/$commits)"
 
 	case "$filter_subdir" in
@@ -374,7 +374,7 @@ do
 	;;
 	esac
 	git update-ref -m "filter-branch: backup" "$orig_namespace$ref" $sha1
-	count=$(($count+1))
+	count=$(expr $count + 1)
 done < "$tempdir"/heads
 
 # TODO: This should possibly go, with the semantics that all positive given
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index ecc6778..da48aaf 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -71,8 +71,8 @@ mark_action_done () {
 	sed -e 1q < "$TODO" >> "$DONE"
 	sed -e 1d < "$TODO" >> "$TODO".new
 	mv -f "$TODO".new "$TODO"
-	count=$(($(grep -ve '^$' -e '^#' < "$DONE" | wc -l)))
-	total=$(($count+$(grep -ve '^$' -e '^#' < "$TODO" | wc -l)))
+	count=$(grep -ve '^$' -e '^#' < "$DONE" | wc -l)
+	total=$(expr $count + $(grep -ve '^$' -e '^#' < "$TODO" | wc -l))
 	printf "Rebasing (%d/%d)\r" $count $total
 	test -z "$VERBOSE" || echo
 }
@@ -205,8 +205,8 @@ nth_string () {
 
 make_squash_message () {
 	if test -f "$SQUASH_MSG"; then
-		COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
-			< "$SQUASH_MSG" | tail -n 1)+1))
+		COUNT=$(expr $(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
+			< "$SQUASH_MSG" | tail -n 1) + 1)
 		echo "# This is a combination of $COUNT commits."
 		sed -n "2,\$p" < "$SQUASH_MSG"
 	else
diff --git a/git-rebase.sh b/git-rebase.sh
index 224cca9..daa347a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -79,7 +79,7 @@ continue_merge () {
 	echo "$prev_head" > "$dotest/prev_head"
 
 	# onto the next patch:
-	msgnum=$(($msgnum + 1))
+	msgnum=$(expr $msgnum + 1)
 	echo "$msgnum" >"$dotest/msgnum"
 }
 
@@ -90,7 +90,7 @@ call_merge () {
 	cmt_name=$(git symbolic-ref HEAD)
 	msgnum=$(cat "$dotest/msgnum")
 	end=$(cat "$dotest/end")
-	eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
+	eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(expr $end - $msgnum)"'
 	eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
 	export GITHEAD_$cmt GITHEAD_$hd
 	git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
@@ -163,7 +163,7 @@ do
 			prev_head=$(cat "$dotest/prev_head")
 			end=$(cat "$dotest/end")
 			msgnum=$(cat "$dotest/msgnum")
-			msgnum=$(($msgnum + 1))
+			msgnum=$(expr $msgnum + 1)
 			onto=$(cat "$dotest/onto")
 			while test "$msgnum" -le "$end"
 			do
@@ -349,7 +349,7 @@ echo "$prev_head" > "$dotest/prev_head"
 msgnum=0
 for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD`
 do
-	msgnum=$(($msgnum + 1))
+	msgnum=$(expr $msgnum + 1)
 	echo "$cmt" > "$dotest/cmt.$msgnum"
 done
 
-- 
1.5.3.5.561.g140d
Previous: Ralf WildenhuesNext: Ralf Wildenhues
Message 4 of 38 in “some shell portability fixes”
  1. 0/5 some shell portability fixesRalf Wildenhues, Nov 6, 2007
  2. 1/5 Avoid a few unportable, needlessly nested "...`...".Ralf Wildenhues, Nov 6, 2007
  3. 2/5 Fix sed script to work with AIX sed.Ralf Wildenhues, Nov 6, 2007
  4. Ralf WildenhuesNov 6, 2007
  5. Ralf WildenhuesNov 6, 2007
  6. Junio C HamanoNov 6, 2007
  7. Add Documentation/CodingStyleJohannes Schindelin, Nov 6, 2007
  8. Andreas EricssonNov 7, 2007
  9. Junio C HamanoNov 7, 2007
  10. Andreas EricssonNov 7, 2007
  11. Add Documentation/CodingStyleJohannes Schindelin, Nov 7, 2007
  12. Robin RosenbergNov 7, 2007
  13. Add Documentation/CodingGuidelinesJohannes Schindelin, Nov 7, 2007
  14. Junio C HamanoNov 7, 2007
  15. Add Documentation/CodingGuidelinesJohannes Schindelin, Nov 8, 2007
  16. Junio C HamanoNov 8, 2007
  17. Johannes SchindelinNov 7, 2007
  18. Wincent ColaiutaNov 7, 2007
  19. Andreas EricssonNov 7, 2007
  20. Jon LoeligerNov 7, 2007
  21. Johannes SchindelinNov 7, 2007
  22. Mike RalphsonNov 8, 2007
  23. 4/5 Fix sed string regex escaping in module_name.Ralf Wildenhues, Nov 6, 2007
  24. 5/5 Avoid "test -o" and "test -a" which are not POSIX, only XSI.Ralf Wildenhues, Nov 6, 2007
  25. Junio C HamanoNov 6, 2007
  26. Mike HommeyNov 6, 2007
  27. Johannes SchindelinNov 6, 2007
  28. Mike RalphsonNov 7, 2007
  29. Johannes SchindelinNov 7, 2007
  30. Mike RalphsonNov 7, 2007
  31. Johannes SchindelinNov 7, 2007
  32. Ralf WildenhuesNov 6, 2007
  33. Nguyen Thai Ngoc DuyNov 7, 2007
  34. Nguyen Thai Ngoc DuyNov 7, 2007
  35. Junio C HamanoNov 7, 2007
  36. Ralf WildenhuesNov 8, 2007
  37. Nguyen Thai Ngoc DuyNov 12, 2007
  38. Miles BaderNov 10, 2007

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.