3 simple steps to make booting/shutdown faster...

Adam Goode adam at spicenitz.org
Sun Feb 17 16:27:14 UTC 2008


Arjan van de Ven wrote:
> Behdad Esfahbod <behdad at behdad.org> wrote:
>> On Sat, 2008-02-16 at 18:40 -0800, Arjan van de Ven wrote: 
>>> * if you do if [ -f FOO -o -f BAR ] in bash, bash will look to see
>>> if BOTH files exist, and then decides that since FOO exits,
>>> everything is fine and executes the if body. Looking for
>>> non-existing files (first time) is expensive.. so splitting this
>>> kind of "if" in two reduces disk seeks and IO. [this kind of split
>>> I had to do in a few places]
>> This should really be fixed in bash to short-circuit.
> 
> well......... not sure it can be done in the bash language.
> (it may well guarantee that both get executed)
> 

From bash info page:

    `EXPRESSION1 || EXPRESSION2'
          True if either EXPRESSION1 or EXPRESSION2 is true.
     The `&&' and `||' operators do not evaluate EXPRESSION2 if the
     value of EXPRESSION1 is sufficient to determine the return value
     of the entire conditional expression.



So, replace "-o" with "||" ? (And "[" with "[[" and "]" with "]]" ?)


Adam

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20080217/7b3dc72c/attachment.sig>


More information about the fedora-devel-list mailing list