A && B ; C
A returns an exit status of zero.
B returns a non-zero exit status.
C, if performed, returns an exit status of zero.
Then, which of the following two will happen (A is taken for granted to be performed in either case):
Bash will perform B and C
Bash will perform B but not C
As an extension to this question, how would we modify the chain to allow for the behaviour of the alternative (1 or 2)?
Edit:
I'm not asking about the meaning of && versus ; .
I know A and B gets executed regardless. The remaining scenario is either C are ignored, because B returned non-zero exit status, or B is skipped over and C is re-evaluated on its own merit.
set -e
is in effect or your computer is a hit by a meteorite just after running theB
command. – Aug 17 '19 at 17:46&&
and;
? – muru Aug 17 '19 at 17:49&&
has higher precedence than;
.A && B; C
is{ A && B; }; C
notA && { B; C; }
(all this is simplified, since;
is not actually an operator, but a separator, and{ A; }
is not exactly equivalent toA
in the shell. – Aug 17 '19 at 18:00