SUDO may not be set, if no parameter or environment variable is passed. This ensures that elevate_priv gets an empty string (as expected) in those cases
This ensures that mismatched permissions/ownership on `${_man_dir}` and `${_man_dir}/man1` don't cause the script to fail.
*If* `${man_dir}/man1` already exists and is writable, OR `${_man_dir}/man1` *doesn't* yet exist, but `${_man_dir}` is
writable, then the script continues without sudo.
If `/man1` doesn't exist, and it's parent isn't writable, we need sudo.
If `/man1` *does* exist, and it's not writable, we need sudo.
This helps ensure that mismatched permission on `_bin_dir` and `_man_dir` don't cause issues.
Also prevents creating man pages owned by root being written to the user's $HOME
This fixes a logic error, where `$_man_dir` is checked to ensure it exists, but not the `man1` subdirectory.
It feels most reasonable to ensure the selected mandir exists, but not that the file structure of the directory is user-managed.
This resets the indention to 4 spaces, reducing the size of the final diff to just code changes and *minor* formatting differences, reducing the effect of indention.
The default is *not* programatically generated in the help menu, as we don't determine this until later. This is intentional, so we can validate the user's choice of command.
This adds support for serveral new command line options (taken from the usage):
"-b, --bin-dir" "Override the bin installation directory [default: ${_bin_dir}]" \
"-m, --man-dir" "Override the man installation directory [default: ${_man_dir}]" \
"-a, --arch" "Override the architecture identified by the installer [default: ${_arch}]" \
"-h, --help" "Display this help message"
This also (coincidentally) allows for $BIN_DIR, $MAN_DIR, and $ARCH to be set to create default settings for these.
These variables are *always* overwritten by the command line arguments.
This diff is unusually large, as my formatter ([shfmt](https://github.com/mvdan/sh)) ran, reformatting the majority of the script.
This also adds a few utilities to the script (`log`/`abort`) and modifies `err` to simply output to stderr.
This allows for more fine grain control over script flow and output, without relying on `echo >&2`.