1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-21 20:35:10 +00:00

Remove obsolete $_COMMAND_ARGV variable.

This commit is contained in:
William Melody 2020-06-07 13:31:46 -07:00
parent 9bf7f782c9
commit d242aed463

30
hosts
View File

@ -1577,7 +1577,7 @@ Description:
Search entries for <search string>.
HEREDOC
search() {
if _blank "${_COMMAND_ARGV[1]:-}"
if [[ -z "${1:-}" ]]
then
help "search"
exit 1
@ -1690,16 +1690,8 @@ _RAW_OPTIONS="${*:-}"
# Parse Options ###############################################################
# Initialize $_COMMAND_ARGV array
#
# This array contains all of the arguments that get passed along to each
# command. This is essentially the same as the program arguments, minus those
# that have been filtered out in the program option parsing loop. This array
# is initialized with $0, which is the program's name.
_COMMAND_ARGV=("${0}")
# Initialize $_CMD and `$_USE_DEBUG`, which can continue to be blank depending
# on what the program needs.
_CMD=""
_COMMAND_PARAMETERS=()
_USE_DEBUG=0
_AUTO_SUDO=0
@ -1746,39 +1738,23 @@ do
_AUTO_SUDO=1
;;
*)
# The first non-option argument is assumed to be the command name.
# All subsequent arguments are added to $_COMMAND_ARGV.
if [[ -z "${_CMD:-}" ]] &&
[[ "${__opt:-}" =~ ${_SUBCOMMANDS_PATTERN} ]]
then
_CMD="${__opt}"
else
_COMMAND_ARGV+=("${__opt}")
_COMMAND_PARAMETERS+=("${__opt}")
fi
;;
esac
done
# Set $_COMMAND_PARAMETERS to $_COMMAND_ARGV, minus the initial element, $0. This
# provides an array that is equivalent to $* and $@ within each command
# function, though the array is zero-indexed, which could lead to confusion.
#
# Use `unset` to remove the first element rather than slicing (e.g.,
# `_COMMAND_PARAMETERS=("${_COMMAND_ARGV[@]:1}")`) because under bash 3.2 the
# resulting slice is treated as a quoted string and doesn't easily get coaxed
# into a new array.
_COMMAND_PARAMETERS=("${_COMMAND_ARGV[@]}")
unset "_COMMAND_PARAMETERS[0]"
_debug printf \
"\${_CMD}: %s\\n" \
"${_CMD}"
_debug printf \
"\${_RAW_OPTIONS} (one per line):\\n%s\\n" \
"${_RAW_OPTIONS}"
_debug printf \
"\${_COMMAND_ARGV[*]}: %s\\n" \
"${_COMMAND_ARGV[*]}"
_debug printf \
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
"${_COMMAND_PARAMETERS[*]:-}"