git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Campbell <pcampbell@kemitix.net>
To: git@vger.kernel.org
Cc: greened@obbligato.org, Paul Campbell <pcampbell@kemitix.net>,
	"Avery Pennarun" <apenwarr@gmail.com>
Subject: [PATCH 3/3] contrib/subtree: replace echo options with printf
Date: Sun, 24 Mar 2013 19:37:43 +0000	[thread overview]
Message-ID: <1364153863-27437-4-git-send-email-pcampbell@kemitix.net> (raw)
In-Reply-To: <1364153863-27437-1-git-send-email-pcampbell@kemitix.net>

Options to echo are not portable. In particular, the echo -e option is
implemented by some shells, including bash, to expand escape sequences.

Use the printf command instead, which is portable and much more reliable.

Only instances of echo and say (a wrapper for echo) where they are used
with options have been replaced with printf.

say_progress() is added to mirror the behaviour of say() in respecting
the -q/--quiet option.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---

This is a better version of the previously submitted patch 
(http://article.gmane.org/gmane.comp.version-control.git/218103) which
added another option to echo.

 contrib/subtree/git-subtree.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 884cbfb..35caf12 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -61,6 +61,13 @@ say()
 	fi
 }
 
+say_progress()
+{
+	if [ -z "$quiet" ]; then
+		printf "%s\r" "$@" >&2
+	fi
+}
+
 assert()
 {
 	if "$@"; then
@@ -311,7 +318,7 @@ copy_commit()
 			GIT_COMMITTER_NAME \
 			GIT_COMMITTER_EMAIL \
 			GIT_COMMITTER_DATE
-		(echo -n "$annotate"; cat ) |
+		(printf "$annotate"; cat ) |
 		git commit-tree "$2" $3  # reads the rest of stdin
 	) || die "Can't copy commit $1"
 }
@@ -592,7 +599,7 @@ cmd_split()
 	eval "$grl" |
 	while read rev parents; do
 		revcount=$(($revcount + 1))
-		say -n "$revcount/$revmax ($createcount)
"
+		say_progress "$revcount/$revmax ($createcount)"
 		debug "Processing commit: $rev"
 		exists=$(cache_get $rev)
 		if [ -n "$exists" ]; then
-- 
1.8.2

      parent reply	other threads:[~2013-03-24 19:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24 19:37 [PATCH 0/3] Improve POSIX compatibility and general portablity Paul Campbell
2013-03-24 19:37 ` [PATCH 1/3] contrib/subtree: stop explicitly using a bash shell Paul Campbell
2013-03-25 17:57   ` Junio C Hamano
2013-03-24 19:37 ` [PATCH 2/3] contrib/subtree: remove use of -a/-o in [ commands Paul Campbell
2013-03-24 21:17   ` Simon Ruderich
2013-03-24 19:37 ` Paul Campbell [this message]

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=1364153863-27437-4-git-send-email-pcampbell@kemitix.net \
    --to=pcampbell@kemitix.net \
    --cc=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=greened@obbligato.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).