Arjan van de Ven wrote: > Behdad Esfahbod <behdad@xxxxxxxxxx> 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
Attachment:
signature.asc
Description: OpenPGP digital signature
-- fedora-devel-list mailing list fedora-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-list