From: Junio C Hamano Date: Fri, 16 May 2014 19:09:29 GMT Subject: Re: [PATCH 10/10] git-submodule.sh: don't use the -a or -b option with the test command Message-ID: In-Reply-To: <20140515155821.GA27279@google.com> Jonathan Nieder writes: > Perhaps something like the following would work? > > tree-wide: convert test -a/-o to && and || > > The interaction with unary operators and operator precedence > for && and || are better known than -a and -o, and for that > reason we prefer them. Replace all existing instances in git > of -a and -o to save readers from the burden of thinking > about such things. > > Add a check-non-portable-shell.pl to avoid more instances of > test -a and -o arising in the future. Yeah, the title is certainly better than "-a or -b option" I see above ;-) and a single tree-wide fix may be OK while the tree is quiescent. I however do think "better known" is much less of an issue than that "-a/-o" is more error prone e.g. 'test -n "$x" -a a = b' is buggy because it does not consider that $x could be "=". > [...] >> - test $status = D -o $status = T && echo "$sm_path" && continue >> + ( test $status = D || test $status = T ) && echo "$sm_path" && continue > > There's no need for a subshell for this. Better to use a block: > > { > test "$status" = D || > test "$status" = T > } && > echo "$sm_path" && > continue Yes.