Merge pull request #1410 from agoose77/master
This commit is contained in:
commit
67850f71bc
13
bash.md
13
bash.md
|
@ -211,15 +211,16 @@ echo ${STR^} #=> "Hello world!" (uppercase 1st letter)
|
||||||
echo ${STR^^} #=> "HELLO WORLD!" (all uppercase)
|
echo ${STR^^} #=> "HELLO WORLD!" (all uppercase)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Default values
|
### Default values
|
||||||
|
|
||||||
| `${FOO:-val}` | `$FOO`, or `val` if not set |
|
| Expression | Description |
|
||||||
| `${FOO:=val}` | Set `$FOO` to `val` if not set |
|
| ----------------- | -------------------------------------------------------- |
|
||||||
| `${FOO:+val}` | `val` if `$FOO` is set |
|
| `${FOO:-val}` | `$FOO`, or `val` if unset (or null) |
|
||||||
| `${FOO:?message}` | Show error message and exit if `$FOO` is not set |
|
| `${FOO:=val}` | Set `$FOO` to `val` if unset (or null) |
|
||||||
|
| `${FOO:+val}` | `val` if `$FOO` is set (and not null) |
|
||||||
|
| `${FOO:?message}` | Show error message and exit if `$FOO` is unset (or null) |
|
||||||
|
|
||||||
The `:` is optional (eg, `${FOO=word}` works)
|
Omitting the `:` removes the (non)nullity checks, e.g. `${FOO-val}` expands to `val` if unset otherwise `$FOO`.
|
||||||
|
|
||||||
Loops
|
Loops
|
||||||
-----
|
-----
|
||||||
|
|
Loading…
Reference in New Issue