From 53ddefa0df021f3d8a9df7141494542fb97b2d9c Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Fri, 27 Jul 2018 15:14:01 +0200 Subject: 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 <= $# --- share/spack/setup-env.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'share/spack') diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index a0321c9223..daa0000977 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -80,14 +80,22 @@ function spack { return fi - _sp_subcommand=$1; shift + _sp_subcommand="" + if [ -n "$1" ]; then + _sp_subcommand="$1" + shift + fi _sp_spec=("$@") # Filter out use and unuse. For any other commands, just run the # command. case $_sp_subcommand in "cd") - _sp_arg="$1"; shift + _sp_arg="" + if [ -n "$1" ]; then + _sp_arg="$1" + shift + fi if [ "$_sp_arg" = "-h" ]; then command spack cd -h else -- cgit v1.2.3-60-g2f50