Use `unset` rather than slicing for bash 3.2 compatibility.

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.
This commit is contained in:
William Melody 2015-10-19 16:26:21 -07:00
parent 6733260385
commit b539cd6136
1 changed files with 7 additions and 2 deletions

9
hosts
View File

@ -255,7 +255,13 @@ 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.
_COMMAND_PARAMETERS=("${_COMMAND_ARGV[@]:1}")
#
# Use `unset` to remove the first element rather than slicing (e.g., not
# `_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"
@ -1070,4 +1076,3 @@ show() {
# Calling the _main function after everything has been defined.
_main