diff --git a/bash.md b/bash.md index 001186ee6..e9bb11ff8 100644 --- a/bash.md +++ b/bash.md @@ -211,15 +211,16 @@ echo ${STR^} #=> "Hello world!" (uppercase 1st letter) echo ${STR^^} #=> "HELLO WORLD!" (all uppercase) ``` - ### Default values -| `${FOO:-val}` | `$FOO`, or `val` if not set | -| `${FOO:=val}` | Set `$FOO` to `val` if not set | -| `${FOO:+val}` | `val` if `$FOO` is set | -| `${FOO:?message}` | Show error message and exit if `$FOO` is not set | +| 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) | -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 -----