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.
Since the regular expressions are essentially repeated, with the only
difference being the capturing groups that have no impact on the delete
operations, assign them to a set of descriptive variables. This makes
things more organized and additionally provides some explanation for
what each regular expression is matching against.
This provides a mechanism for removing exact IP and hostname pairs.
The existing search string functionality should continue to function as
it did previously.
The `disable` regular expressions avoid matching against commented lines
by excluding '#' characters at the beginning of the line. However, the
IP portion of the record is at the beginning of non-commented lines, so
in order to match these IPs the `target_regex_ip` needs to have the
search term checked against the beginning of the line. Therefore, the
`[^#]` at the beginning of `target_regex_ip` must be removed to make
`search_term` properly match these IPs.
These variables are used within regular expressions, but as the program
evolves they are not always in constant use. Exporting these variables
silences ShellCheck warnings and makes them available to subshells.
This is an application of the approach to `sed` calls that was included
in 94ca8bf
In order to make editing more precise, `sed` regular expressions only
match exact occurrences of the search string within each entry column.
* master:
Exit with "Not found" message on failed search in `enable`/`disable`
Bump version to 1.5.0
Print confirmation feedback in `add` on success.
Declare and assign separately to avoid masking return values.
Add `brew tap` command to `brew install` in Readme.
In order to make editing more precise, sed regular expressions only
match exact occurrences of the search string within each entry column.
In order to properly handle tab and space separators in a portable
manner, a set of global variables are included that provide strings
of those characters.
The capitalized version of this variable makes it easier to override,
even though this is not technically part of the external API. There is
no known downside of using the capitalized version of the variable.
This addition requires a number of changes including:
- the addition of a new `_join` function
- reformatting of the `add` function to facilitate the longer lines