Make sure multiple `nvm run` arguments get passed through to node/iojs properly.
Fixes #641.
diff --git a/nvm.sh b/nvm.sh
index e25d3b5..07702f6 100644
--- a/nvm.sh
+++ b/nvm.sh
@@ -1292,18 +1292,27 @@
local OUTPUT
local EXIT_CODE
+ local ZHS_HAS_SHWORDSPLIT_UNSET
+ ZHS_HAS_SHWORDSPLIT_UNSET=1
+ if nvm_has "setopt"; then
+ ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?)
+ setopt shwordsplit
+ fi
if [ "_$VERSION" = "_N/A" ]; then
echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2
EXIT_CODE=1
elif [ "$NVM_IOJS" = true ]; then
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
- OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
+ OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs $ARGS)"
EXIT_CODE="$?"
else
echo "Running node $VERSION"
- OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
+ OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)"
EXIT_CODE="$?"
fi
+ if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
+ unsetopt shwordsplit
+ fi
if [ -n "$OUTPUT" ]; then
echo "$OUTPUT"
fi
diff --git "a/test/slow/nvm run/Running \"nvm run --harmony --version\" should work" "b/test/slow/nvm run/Running \"nvm run --harmony --version\" should work"
new file mode 100755
index 0000000..dfb90a9
--- /dev/null
+++ "b/test/slow/nvm run/Running \"nvm run --harmony --version\" should work"
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+die () { echo $@ ; exit 1; }
+
+. ../../../nvm.sh
+
+nvm run 0.10.7 --harmony --version
+[ "_$(nvm run 0.10.7 --harmony --version 2>/dev/null | tail -1)" = "_v0.10.7" ] || die "\`nvm run --harmony --version\` failed to run with the correct version"
+
diff --git "a/test/slow/nvm run/Running \"nvm run 0.x\" should work" "b/test/slow/nvm run/Running \"nvm run 0.x\" should work"
index cc56601..9bcf97f 100755
--- "a/test/slow/nvm run/Running \"nvm run 0.x\" should work"
+++ "b/test/slow/nvm run/Running \"nvm run 0.x\" should work"
@@ -5,5 +5,5 @@
. ../../../nvm.sh
-[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the correct version"
+[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the correct version"