Re: [PATCH 03/20] contrib/examples/git-commit.sh: avoid "test <cond> -a/-o <cond>"
- From
David Aguilar <davvid@gmail.com>
- Date
- Jun 10, 2014, 18:36 UTC
- Message-ID
- <20140610183638.GA72751@gmail.com>
- In-Reply-To
- <1402066563-28519-4-git-send-email-gitter.spiros@gmail.com>
On Fri, Jun 06, 2014 at 07:55:46AM -0700, Elia Pinto wrote:
Show 23 quoted lines
> The construct is error-prone; "test" being built-in in most modern
> shells, the reason to avoid "test <cond> && test <cond>" spawning
> one extra process by using a single "test <cond> -a <cond>" no
> longer exists.
>
> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> ---
> contrib/examples/git-commit.sh | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/examples/git-commit.sh b/contrib/examples/git-commit.sh
> index 5cafe2e..934505b 100755
> --- a/contrib/examples/git-commit.sh
> +++ b/contrib/examples/git-commit.sh
> @@ -51,7 +51,7 @@ run_status () {
> export GIT_INDEX_FILE
> fi
>
> - if test "$status_only" = "t" -o "$use_status_color" = "t"; then
> + if test "$status_only" = "t" || test "$use_status_color" = "t"; then
> color=
> else
> color=--nocolorIt might be worth moving the "then" to the next line so that it's consistent with the preferred sh style and with the rest of the script.
If we do that then there's one less line that would need to be touched by a future style-fix patch.
Show 11 quoted lines
> @@ -296,7 +296,7 @@ t,,,[1-9]*) > die "No paths with -i does not make sense." ;; > esac > > -if test ! -z "$templatefile" -a -z "$log_given" > +if test ! -z "$templatefile" && test -z "$log_given" > then > if test ! -f "$templatefile" > then > -- > 1.7.10.4
-- David