Make sure multiple `nvm run` arguments get passed through to node/iojs properly.

Fixes #641.
master
Jordan Harband 2015-02-07 10:08:20 -08:00
parent 59e27f8108
commit be56ff3b2e
3 changed files with 21 additions and 3 deletions

13
nvm.sh
View File

@ -1292,18 +1292,27 @@ nvm() {
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

View File

@ -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"

View File

@ -5,5 +5,5 @@ die () { echo $@ ; exit 1; }
. ../../../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"