All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Martin Erik Werner <martinerikwerner@gmail.com>
Cc: Simon vanaf Telefoon <s.oosthoek@xs4all.nl>,
	Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org, trsten@science-computing.de,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: Re: [PATCH] shell-prompt: clean up nested if-then
Date: Mon, 18 Feb 2013 15:07:02 -0800	[thread overview]
Message-ID: <7vtxp98bmx.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1361228206.17734.4.camel@mas> (Martin Erik Werner's message of "Mon, 18 Feb 2013 23:56:46 +0100")

Martin Erik Werner <martinerikwerner@gmail.com> writes:

> On Mon, 2013-02-18 at 21:31 +0100, Simon vanaf Telefoon wrote:
>> Hi all, sorry for top posting :-( blame the phone and k9
>> 
>> I have a small issue with the use of test instead of [
>> If that only applies to this section of the entire file. 
>> Coding style has some value.
>> 
>> Combining nested ifs with && seems harmless enough, though should be
>> well tested.
>> 
>> Cheers
>> Simon 
>> 
>
> Ah, indeed, I looked around a bit more, and as per
> http://mywiki.wooledge.org/BashPitfalls it seems like 'test' is bad to use with multiple &&'s anyways.

I think you are misreading a suggestion that is somewhat misguided
(yes "[ <condition> && <another> ]" does not make sense, but that is
not applicable to "test <conditon> && test <another>"); ignore it.

It is fine to write "test <condition> && test <another>" and that
works portably to even pre-posix systems.

But the existing code the patch touches favors [] over test
consistently; that alone is a good reason to stick with [] in _this_
script, even though it is against Git's overall shell script style.

  parent reply	other threads:[~2013-02-18 23:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1361204512.4758.10.camel@mas>
2013-02-18 16:23 ` [PATCH] shell-prompt: clean up nested if-then Martin Erik Werner
2013-02-18 19:10   ` Jonathan Nieder
     [not found]     ` <0c94f24b-f7ee-4699-87a7-6861b927cea4@email.android.com>
2013-02-18 22:56       ` Martin Erik Werner
2013-02-18 22:59         ` [PATCH v2] " martinerikwerner
2013-02-18 23:28           ` Jonathan Nieder
2013-02-18 23:07         ` Junio C Hamano [this message]
2013-02-19  8:17           ` [PATCH] " Simon Oosthoek
2013-02-19 16:28             ` 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=7vtxp98bmx.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=martinerikwerner@gmail.com \
    --cc=s.oosthoek@xs4all.nl \
    --cc=trsten@science-computing.de \
    /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.