Formats the `install` script in accordance with Google's Shell Style Guide using `shfmt` and applies fixes for issues that were found by the static analysis tool `shellcheck`.
Style changes
- Consistent two space indentation.
- Consistent formatting of `for ... do` loops and `if ... then` code blocks.
- Consistent brace-delimiting of variable names.
- Consistent upper-case spelling of variable names.
- Consistent alphabetic ordering of packages installed/removed by `apt-get`.
- Explicit error codes for `exit` commands.
- All error messages sent to `STDERR`.
- Use of `[[ -z "${VAR}" ]]` instead of `[[ "${VAR}" == "" ]]`.
Shellcheck fixes
- Double quote variables to prevent globbing and word splitting. [SC2086]
- Use `{ cmd1; cmd2; } >> file` instead of individual redirects. [SC2129]
- Useless `echo`. Instead of `echo $(cmd)`, just use `cmd`. [SC2005]
- To redirect stdout+stderr, `2>&1` must be last. [SC2069]
- `read` without `-r` will mangle backslashes. [SC2162]
The variable `NEKO_IMAGES` is purposefully left unquoted in the `for ... do` loop on L245 since it is an array where we do want word splitting to happen.
Signed-off-by: Aaron <admin@datahoarder.dev>
The shell built-in "echo" preserves newlines by default, so there is no need to issue a new echo command for every new line in a formatted text. This version is not only faster, but easier and less error prone to edit as well.
Signed-off-by: Aaron <admin@datahoarder.dev>