git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elia Pinto <gitter.spiros@gmail.com>
To: git@vger.kernel.org
Cc: Elia Pinto <gitter.spiros@gmail.com>
Subject: [PATCH 14/15] git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin
Date: Thu,  4 Feb 2016 10:20:58 +0000	[thread overview]
Message-ID: <1454581259-57095-1-git-send-email-gitter.spiros@gmail.com> (raw)

expr is considered generally antiquated. It is best to use for arithmetic operations
the shell $((..)).

To quote POSIX:

"The expr utility has a rather difficult syntax [...] In many cases, the arithmetic
and string features provided as part of the shell command language are easier to use
than their equivalents in expr. Newly written scripts should avoid expr in favor of
the new features within the shell."

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 git-am.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index ee61a77..4f8148e 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -298,7 +298,7 @@ split_patches () {
 		this=0
 		for stgit in "$@"
 		do
-			this=$(expr "$this" + 1)
+			this=$(( "$this" + 1 ))
 			msgnum=$(printf "%0${prec}d" $this)
 			# Perl version of StGIT parse_patch. The first nonemptyline
 			# not starting with Author, From or Date is the
@@ -656,14 +656,14 @@ last=$(cat "$dotest/last")
 this=$(cat "$dotest/next")
 if test "$skip" = t
 then
-	this=$(expr "$this" + 1)
+	this=$(( "$this" + 1 ))
 	resume=
 fi
 
 while test "$this" -le "$last"
 do
 	msgnum=$(printf "%0${prec}d" $this)
-	next=$(expr "$this" + 1)
+	next=$(( "$this" + 1 ))
 	test -f "$dotest/$msgnum" || {
 		resume=
 		go_next
-- 
2.5.0

             reply	other threads:[~2016-02-04 10:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 10:20 Elia Pinto [this message]
2016-02-04 10:20 ` [PATCH 15/15] t4032-diff-inter-hunk-context.sh: replace using expr for arithmetic operations with the equivalent shell builtin Elia Pinto
2016-02-04 11:14 ` [PATCH 14/15] git-am.sh: " Johannes Schindelin
2016-02-04 11:53   ` Elia Pinto
2016-02-04 12:01     ` Johannes Schindelin
2016-02-04 19:33 ` Junio C Hamano
2016-02-04 19:39   ` Eric Sunshine
2016-02-05 12:50   ` Elia Pinto
2016-02-04 19:46 ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454581259-57095-1-git-send-email-gitter.spiros@gmail.com \
    --to=gitter.spiros@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).