Fix shift warning on zsh (#8805)

When using zsh, trying to shift when there are no arguments left results
in warnings like this: spack:shift:22: shift count must be <= $#
This commit is contained in:
Michael Kuhn 2018-07-27 15:14:01 +02:00 committed by Adam J. Stewart
parent 90f7fca194
commit 53ddefa0df

View File

@ -80,14 +80,22 @@ function spack {
return return
fi fi
_sp_subcommand=$1; shift _sp_subcommand=""
if [ -n "$1" ]; then
_sp_subcommand="$1"
shift
fi
_sp_spec=("$@") _sp_spec=("$@")
# Filter out use and unuse. For any other commands, just run the # Filter out use and unuse. For any other commands, just run the
# command. # command.
case $_sp_subcommand in case $_sp_subcommand in
"cd") "cd")
_sp_arg="$1"; shift _sp_arg=""
if [ -n "$1" ]; then
_sp_arg="$1"
shift
fi
if [ "$_sp_arg" = "-h" ]; then if [ "$_sp_arg" = "-h" ]; then
command spack cd -h command spack cd -h
else else