From: Junio C Hamano Date: Mon, 18 Feb 2013 23:07:02 GMT Subject: Re: [PATCH] shell-prompt: clean up nested if-then Message-ID: <7vtxp98bmx.fsf@alter.siamese.dyndns.org> In-Reply-To: <1361228206.17734.4.camel@mas> Martin Erik Werner 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 "[ && ]" does not make sense, but that is not applicable to "test && test "); ignore it. It is fine to write "test && test " 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.