Add more explanation of chained operators

rowlap
2018-10-05 09:29:33 +01:00
parent 8b33f8de8d
commit 7458bfd3d9

@@ -29,5 +29,16 @@ For the code sample above, if the script was run with stdout closed for any reas
If an `if` clause is used instead, this problem is avoided. If an `if` clause is used instead, this problem is avoided.
### Boring detail:
We can think of the example above as
```sh
((([[ $dryrun ]]) && echo "Would delete file") || rm file)
```
expressing the left-associativity of the `&&` `||` operators.
Whenever a command (strictly, a pipeline) succeeds or fails, the execution proceeds following the next `&&` (for success) or `||` (for failure).
### Exceptions ### Exceptions
Ignore this warning when you actually do intend to run C when either A or B fails. Ignore this warning when you actually do intend to run C when either A or B fails.