From: Jeff King <peff@peff.net>
To: CB Bailey <charles@hashpling.org>
Cc: Michele Locati <michele@locati.it>,
git@vger.kernel.org, Ian Campbell <ijc@hellion.org.uk>
Subject: Re: [PATCH] filter-branch: use printf instead of echo -e
Date: Tue, 20 Mar 2018 00:22:45 -0400 [thread overview]
Message-ID: <20180320042245.GA13302@sigill.intra.peff.net> (raw)
In-Reply-To: <20180319153945.kchupu43cpcbg25n@hashpling.org>
On Mon, Mar 19, 2018 at 03:39:46PM +0000, CB Bailey wrote:
> > diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> > index 1b7e4b2cd..21d84eff3 100755
> > --- a/git-filter-branch.sh
> > +++ b/git-filter-branch.sh
> > @@ -627,7 +627,7 @@ then
> > print H "$_:$f\n" or die;
> > }
> > close(H) or die;' || die "Unable to save state")
> > - state_tree=$(/bin/echo -e "100644 blob $state_blob\tfilter.map" | git mktree)
> > + state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree)
> > if test -n "$state_commit"
> > then
> > state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" -p "$state_commit")
>
> I think the change from 'echo -e' to printf is good because of the
> better portability reason that you cite.
>
> Looking at the change, I am now curious as to why '/bin/echo' is used.
> Testing on a Mac, bash's built in 'echo' recognizes '-e' whereas
> '/bin/echo' does not. This is just an observation, I still prefer the
> move to 'printf' that you suggest.
Right. Moving them to just "echo -e" would work on systems where /bin/sh
is bash, but not elsewhere (e.g., Debian systems with "dash" whose
built-in echo doesn't understand "-e").
So my guess as to why /bin/echo was used is that on Linux systems it's
_more_ predictable and portable, because you know you're always going to
get the GNU coreutils version, which knows "-e". Even if you're using a
non-bash shell.
But on non-Linux systems, who knows what system "echo" you'll get. :)
Author cc'd in case there's something more interesting going on.
-Peff
next prev parent reply other threads:[~2018-03-20 4:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 14:49 [PATCH] filter-branch: use printf instead of echo -e Michele Locati
2018-03-19 15:39 ` CB Bailey
2018-03-20 4:22 ` Jeff King [this message]
2018-03-20 9:53 ` Ian Campbell
2018-03-20 10:21 ` Michele Locati
2018-03-19 15:52 ` [PATCH v2] " Michele Locati
2018-03-19 18:00 ` Junio C Hamano
2018-03-21 21:50 ` Johannes Schindelin
2018-03-22 13:40 ` Michele Locati
2018-03-23 9:35 ` Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180320042245.GA13302@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=charles@hashpling.org \
--cc=git@vger.kernel.org \
--cc=ijc@hellion.org.uk \
--cc=michele@locati.it \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).