summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorMichael Kuhn <suraia@ikkoku.de>2018-07-27 15:14:01 +0200
committerAdam J. Stewart <ajstewart426@gmail.com>2018-07-27 08:14:01 -0500
commit53ddefa0df021f3d8a9df7141494542fb97b2d9c (patch)
tree25657abc51bd6372a6401f510d0114ebf50f6288 /share
parent90f7fca1940a1779426f979f0afe72ae9905fd30 (diff)
downloadspack-53ddefa0df021f3d8a9df7141494542fb97b2d9c.tar.gz
spack-53ddefa0df021f3d8a9df7141494542fb97b2d9c.tar.bz2
spack-53ddefa0df021f3d8a9df7141494542fb97b2d9c.tar.xz
spack-53ddefa0df021f3d8a9df7141494542fb97b2d9c.zip
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 <= $#
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.sh12
1 files changed, 10 insertions, 2 deletions
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