diff --git a/bash.md b/bash.md index 3f6b85efb..e9bb11ff8 100644 --- a/bash.md +++ b/bash.md @@ -1,4 +1,4 @@ -(--- +--- title: Bash scripting category: CLI layout: 2017/sheet @@ -211,17 +211,17 @@ echo ${STR^} #=> "Hello world!" (uppercase 1st letter) echo ${STR^^} #=> "HELLO WORLD!" (all uppercase) ``` - ### Default values -| `${FOO:-val}` | `$FOO`, or `val` if unset (or null) | -| `${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) | +| Expression | Description | +| ----------------- | -------------------------------------------------------- | +| `${FOO:-val}` | `$FOO`, or `val` if unset (or null) | +| `${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) | Omitting the `:` removes the (non)nullity checks, e.g. `${FOO-val}` expands to `val` if unset otherwise `$FOO`. - Loops ----- {: .-three-column}