git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paolo Giarrusso <p.giarrusso@gmail.com>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Tay Ray Chuan <rctay89@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Fwd: [PATCH] git-subtree: Avoid using echo -n even indirectly
Date: Wed, 9 Oct 2013 14:03:24 +0200	[thread overview]
Message-ID: <CAAcnjCQCJYbYUkTK+ZM6xFe=u1mj9iHetaG--yg3Qzn0_Ty0hg@mail.gmail.com> (raw)
In-Reply-To: <vpqy562y9b8.fsf@anie.imag.fr>

On Wed, Oct 9, 2013 at 1:26 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Paolo Giarrusso <p.giarrusso@gmail.com> writes:
>
>> Otherwise, one could
>> change say to use printf, but that's more invasive.
>
> "invasive" in the sense that it impacts indirectly more callers, but are
> there really cases where "echo" is needed when calling "say"? Aren't
> there other potential bugs when arbitrary strings are passed to "say",
> that would be fixed by using printf once and for all?

(1) Changing the implementation of say to use printf "%s\n" would be
trivial, and I think would address your concerns.

But I was concerned about code duplication; one could additionally
make say reusable in this single call site, instead of inlining and
customizing it by replacing the "\n" with "\r". But for that, you need
to either
(2) add an explicit \n to all callers (invasive & error prone), or
(3) make `say` parse the `-n` option and conditionally add "\n" to the
format string or to a final argument, if -n is not specified; this
would affect no current caller, but complicate the implementation of
say. Doing that for just one call site has too much potential for
breakage, so I'm not sure I'd do it. (I'm not even sure on what should
`say` do when `-n` is not the first argument).

Options (1), (2) and (3) are mutually alternative; my favorite is (1).

I can see your points about opportunity, especially after looking at
the commit message of the patch of yours you linked.

> The patch would look like the one I did in 89b0230a20 (Wed Aug 7 2013,
> die_with_status: use "printf '%s\n'", not "echo").

I see your point. But note that using printf like in die_with_status
after that commit wouldn't be reusable here in all call sites, because
it always prints a newline.

Cheers,
-- 
Paolo G. Giarrusso - Ph.D. Student, Philipps-University Marburg
http://www.informatik.uni-marburg.de/~pgiarrusso/

  reply	other threads:[~2013-10-09 12:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09  3:57 [PATCH] git-subtree: Avoid using echo -n even indirectly Paolo G. Giarrusso
2013-10-09 10:20 ` Tay Ray Chuan
     [not found]   ` <CAAcnjCT1bdR+9kDW=q_326OhiSMm3_j-yOh0-ayTkObK3bZ3bQ@mail.gmail.com>
2013-10-09 10:32     ` Fwd: " Paolo Giarrusso
2013-10-09 10:46       ` Johannes Sixt
2013-10-09 11:26       ` Matthieu Moy
2013-10-09 12:03         ` Paolo Giarrusso [this message]
2013-10-09 19:48           ` Jeff King
2013-10-09 21:11       ` Jonathan Nieder
2013-10-11  9:32         ` Paolo Giarrusso
  -- strict thread matches above, loose matches on Subject: below --
2013-10-28 14:04 Paolo Giarrusso

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='CAAcnjCQCJYbYUkTK+ZM6xFe=u1mj9iHetaG--yg3Qzn0_Ty0hg@mail.gmail.com' \
    --to=p.giarrusso@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=rctay89@gmail.com \
    /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).