You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐚 Refactors branching, adjusts error messaging, and formatting...
... Formatting changes; indentation, new lines, line breaks and quotes
**Notes**
`if` branching that do **not** have `elif` block(s) are simplified,
eg...
```bash
if [[ "${variable}" == 'spam' ]]; then
printf 'Consuming spam from variable -> %s\n' "${variable}"
else
printf 'Inserting spam into variable'
variable='spam'
fi
```
... are changed to...
```bash
[[ "${variable}" == 'spam' ]] && {
printf 'Reading spam from variable -> %s\n' "${variable}"
} || {
printf 'Inserting spam into variable'
variable='spam'
}
```
------
Checking if a variable is empty with `-z` option...
```bash
if [[ -z "${variable}" ]]; then
printf >&2 'Empty variable -> %s\n' "${variable}"
fi
```
... is not as trustworthy as checking if character count is above
zero...
```bash
((${#variable})) || {
printf >&2 'Empty variable -> %s\n' "${variable}"
}
```
... Nor is checking if a variable is assigned with `-n` option...
```bash
if [[ -n "${variable}" ]]; then
printf 'Detected variable -> %s\n' "${variable}"
fi
```
... as trustworthy as checking if character count is above zero...
```bash
((${#variable})) && {
printf 'Detected variable -> %s\n' "${variable}"
}
```
------
Messages printed to standard error (STDERR) are now standardized to show
where messages are directed to prior to the content, eg...
```bash
printf 'Error message' >&2
```
... are changed to...
```bash
printf >&2 'Error message'
```
0 commit comments