From: Paul Campbell Date: Sun, 24 Mar 2013 19:37:43 GMT Subject: [PATCH 3/3] contrib/subtree: replace echo options with printf Message-ID: <1364153863-27437-4-git-send-email-pcampbell@kemitix.net> 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 --- 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