mirror of
https://github.com/octoleo/hosts.git
synced 2024-09-22 18:19:09 +00:00
Remove obsolete $_COMMAND_ARGV
variable.
This commit is contained in:
parent
9bf7f782c9
commit
d242aed463
30
hosts
30
hosts
@ -1577,7 +1577,7 @@ Description:
|
|||||||
Search entries for <search string>.
|
Search entries for <search string>.
|
||||||
HEREDOC
|
HEREDOC
|
||||||
search() {
|
search() {
|
||||||
if _blank "${_COMMAND_ARGV[1]:-}"
|
if [[ -z "${1:-}" ]]
|
||||||
then
|
then
|
||||||
help "search"
|
help "search"
|
||||||
exit 1
|
exit 1
|
||||||
@ -1690,16 +1690,8 @@ _RAW_OPTIONS="${*:-}"
|
|||||||
|
|
||||||
# Parse 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=""
|
_CMD=""
|
||||||
|
_COMMAND_PARAMETERS=()
|
||||||
_USE_DEBUG=0
|
_USE_DEBUG=0
|
||||||
_AUTO_SUDO=0
|
_AUTO_SUDO=0
|
||||||
|
|
||||||
@ -1746,39 +1738,23 @@ do
|
|||||||
_AUTO_SUDO=1
|
_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:-}" ]] &&
|
if [[ -z "${_CMD:-}" ]] &&
|
||||||
[[ "${__opt:-}" =~ ${_SUBCOMMANDS_PATTERN} ]]
|
[[ "${__opt:-}" =~ ${_SUBCOMMANDS_PATTERN} ]]
|
||||||
then
|
then
|
||||||
_CMD="${__opt}"
|
_CMD="${__opt}"
|
||||||
else
|
else
|
||||||
_COMMAND_ARGV+=("${__opt}")
|
_COMMAND_PARAMETERS+=("${__opt}")
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
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 \
|
_debug printf \
|
||||||
"\${_CMD}: %s\\n" \
|
"\${_CMD}: %s\\n" \
|
||||||
"${_CMD}"
|
"${_CMD}"
|
||||||
_debug printf \
|
_debug printf \
|
||||||
"\${_RAW_OPTIONS} (one per line):\\n%s\\n" \
|
"\${_RAW_OPTIONS} (one per line):\\n%s\\n" \
|
||||||
"${_RAW_OPTIONS}"
|
"${_RAW_OPTIONS}"
|
||||||
_debug printf \
|
|
||||||
"\${_COMMAND_ARGV[*]}: %s\\n" \
|
|
||||||
"${_COMMAND_ARGV[*]}"
|
|
||||||
_debug printf \
|
_debug printf \
|
||||||
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
|
"\${_COMMAND_PARAMETERS[*]:-}: %s\\n" \
|
||||||
"${_COMMAND_PARAMETERS[*]:-}"
|
"${_COMMAND_PARAMETERS[*]:-}"
|
||||||
|
Loading…
Reference in New Issue
Block a user