All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Uwe Storbeck <uwe@ibr.ch>, git@vger.kernel.org
Subject: Re: [PATCH] test-lib.sh: use printf instead of echo
Date: Thu, 20 Mar 2014 09:42:00 -0700	[thread overview]
Message-ID: <xmqq4n2s255z.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140320001718.GM15625@google.com> (Jonathan Nieder's message of "Wed, 19 Mar 2014 17:17:18 -0700")

Jonathan Nieder <jrnieder@gmail.com> writes:

> Junio C Hamano wrote:
> ...
>> I am a bit reluctant to name the helper "sane_echo" to declare "echo
>> that interprets backslashes in the string is insane", though.  For
>> these "print a single line" uses, we are only interested in using a
>> subset of the features offered by 'echo', but that does not mean the
>> other features we do not want to trigger in our use is of no use to
>> any sane person.
>
> In a portable script, uncareful use of 'echo' is always insane.

I agree that makes sense and I actually think that it is a bit
stronger than that.  If a script is meant to be portable, there is
no way to use "echo" on a string whose contents is unknown sanely.
There is no "careful use is OK".

> In a script tailored to an environment where echo behaves consistently
> it is perfectly reasonable to use 'echo', but that's a different
> story.  In the context of git, saying "Here is the thing you should
> always use instead of echo" is a good thing, in my opinion.

That is true in my opinion, but that thing is also what you should
always use instead of "printf '%s\n'".  A guideline more useful for
the users is "Here is the thing you should always use when literally
emitting a single line.", isn't it?

  reply	other threads:[~2014-03-20 16:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 23:57 [PATCH] test-lib.sh: use printf instead of echo Uwe Storbeck
2014-03-15  0:18 ` Jonathan Nieder
2014-03-17 19:26   ` Junio C Hamano
2014-03-18 22:18     ` Jonathan Nieder
2014-03-19 17:17       ` Junio C Hamano
2014-03-19 17:22         ` David Kastrup
2014-03-19 19:24           ` Junio C Hamano
2014-03-20  0:17         ` Jonathan Nieder
2014-03-20 16:42           ` Junio C Hamano [this message]
2014-03-15  8:59 ` Johannes Sixt
2014-03-17 18:38   ` Uwe Storbeck
2014-03-17 18:39 ` [PATCH v2] " Uwe Storbeck
2014-03-18  0:14 ` [PATCH v3] test-lib.sh: do not "echo" externally supplied strings Uwe Storbeck
2014-03-18 18:47   ` Junio C Hamano

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=xmqq4n2s255z.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=uwe@ibr.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.