I am curious about the logic behind &&
in continuous commands execution in shell.
Lets see an example: command_a && command_b && command_c
In shell, this means that once a command fails, the consequent commands will not execute and the chain should stop.
If we replace each command by its exit code, the chain becomes, for example this expression 0 && 1 && 0
. (command_a
succeed, command_b
failed, command_c
succeed)
If we try evaluating this expression, the evaluation should stop right after the first command, 0
value.
If &&
logic is replaced by ||
, the expression would be more fit to the meaning of original chained command.
0 || 1 || 0
.
Expression's evaluation stops after command_b
execution