Re: [PATCH] shell-prompt: clean up nested if-then
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:56:11
Martin Erik Werner [off-list ref] writes:
On Mon, 2013-02-18 at 21:31 +0100, Simon vanaf Telefoon wrote:quoted
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 SimonAh, 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.