Skip to content
Snippets Groups Projects
Commit 370957da authored by Thomas Junier's avatar Thomas Junier
Browse files

rewrote if-thrn-else

parent 89e07750
No related branches found
No related tags found
No related merge requests found
......@@ -285,22 +285,23 @@ Loop control: `break [n]`, `continue [n]`
Conditionals
------------
### `if - then - else`
```bash
if cmd1; then
list1; # iff cmd1 succeeds
elif cmd2; then
list1; # iff cmd1 fails but cmd2 succeeds
else
alt; # otherwise
fi
```
`cmd?` may be _any_ commands (often `(())` or `[[]]`); `list?` and `alt`
are lists.
There are $\geq 0$ `elif` clauses, and $\leq 1$ `else` clause.
### _if - then - else_
| `if` _`test-list1`_`;` `then`
| _`consequent-list1`_`;`
| `elif` _`test-list2`_`;` `then`
| _`consequent-list2`_`;`
| `else`
| _`alt-list`_`;`
| `fi`
_`consequent-list`_ _n_ is executed iff _`test-list`_ _n_ succeeds; _`alt-list`_
is executed if none of the _`test-list`_s succeeds. \
_`test-list?`_ is often a `(())` or `[[]]` conditional but may be _any_ lists,
including a simple command.
The `else` and `elif` clauses are optional, there may be more than one `elif`
clause.
### `case - in`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment