[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem around brackets, && and ||
From: |
Marc Herbert |
Subject: |
Re: Problem around brackets, && and || |
Date: |
Tue, 04 May 2010 13:16:09 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4 |
Le 03/05/2010 20:25, Greg Wooledge a écrit :
> Use if/then/else/fi instead of && ||. Using && || is dangerous, as I've
> explained here:
>
> http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
Also note that using "&&" instead of "if" makes your script totally
incompatible with "set -e", even when using "&&" alone.
Using || alone instead of an "else" is 95% compatible
with "set -e". The 5% caveat is practically the same than the one
documented in Greg FAQ above: the dependent clause must succeed.