GitHub's syntax highlighting doesn't work well when strings contain
function names with parentheses, so add character to the beginning of
the string to see whether this makes it better.
Using `sudo` within a script is generally considered poor practice, so
by default an error message is printed when the user attempts to perform
a write operation without sufficient permissions.
One way to deal avoid this error message is to alias `hosts` to `sudo
hosts`, but this then requires `sudo` for all operations and not just
write operations.
The new `--auto-sudo` option flag provides a way to automatically invoke
a write command with `sudo` when the user doesn't have write
permissions.
In order to provide cleaner documentation for this option, include more
option documentation in README.md.
When `$*` is specified with quotes and braces as `"${*}"`, a blank
argument array results in an error in older versions of bash. Remove
the braces to avoid this error.
Braces are only required in certain cases, but the cognitive overhead in
keeping track of which cases require braces can be reduced by simply
always using them.
Example: `${NAME}`
Retain more widely-used braces `$NAME` convention in documentation.
The `[[ ... ]] && ...` conditional style results in non-zero exits when
the test is false. Moving this to a traditional `if..then` style avoids
this behavior while also being more explicit about the objective of the
code. `|| return 0` or `|| exit 0` could have been added as an
alternative way to avoid the non-zero exit behavior, but is not used in
this case because the traditional `if..then` style is more common.
The `--force` option is passed to the function in `$_COMMAND_ARGV`,
which means that assigning arguments from positions in this array leads
to unexpected behavior depending on where in the argument list `--force`
is included. As a result, the `remove` function must parse the
arguments, removing the `--force` argument before assigning function
arguments to local variables.
resolves#2
The example assignment should have balanced quotes to avoid any copy /
paste errors or reader confusion. Remove the 'not' since it's clearer if
this is used as a parenthetical example of slicing.
Use `unset` to remove the first element of `$_COMMAND_PARAMETERS` rather
than slicing because under bash 3.2 the resulting slice is treated as a
quoted string and doesn't easily get coaxed back into an array.