[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash style of if-then-else?

From: Sven Mascheck
Subject: Re: Bash style of if-then-else?
Date: Fri, 24 Sep 2010 11:28:50 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Sep 24, 2010 at 09:22:50AM +0100, Marc Herbert wrote:

> [...]
> For longer conditions brackets are easier to "parse"; the reader has no
> doubt where it ends.
> By the way I wonder if this makes any difference to the actual parser.
> On the other hand some people explain that long conditions are bad
> practice anyway, and that you should write:
>      test x && test y || test z

which, on the other hand, people sometimes use as replacement for

   if test x; then test y; else test z; fi

although it behaves differently. In the former, test z is also
executed if test y fails.  It's even more unintuitive if you're
not using test but arbitrary commands:

test x && cmd1 || cmd2

(again: cmd2 is even executed if cmd1 fails)

Randal Schwartz once mentioned the idea of a "Dangerous Use Of And-Or" award :)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]