From b539cd61365e73572a51dcca1e64a4007dcaa6a2 Mon Sep 17 00:00:00 2001 From: William Melody Date: Mon, 19 Oct 2015 16:26:21 -0700 Subject: [PATCH] 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. --- hosts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hosts b/hosts index 37cf6ab..ab98088 100755 --- a/hosts +++ b/hosts @@ -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 -