Exit codes and errors
8 min&& and || are not if
They bind equally, and to the left.
a && b runs b only if a succeeded. a || b runs b only if a failed. So far so good.
But they have the same precedence and group to the left, so a || b && c runs as (a || b) && c — which is not what the English words suggest, and is a real source of scripts that do the wrong thing on the failure path.
Try this
The a && b || c idiom is the one to be careful with. It reads like if-then-else and is not: if b itself fails, c runs too.
Try this
When you mean if-then-else, write if. It is three more words and it cannot surprise you.
$
Files
| Mode | Links | Size | Name |
|---|---|---|---|
| -rw-r--r-- | 1 | 95 | changelog.md |
| -rw-r--r-- | 1 | 62 | roster.txt |