Merge pull request #1011 from dohse/keep-parameters

[Fix] Do not modify args of sourcing script when parsing `--install`/`--no-use` arg

Fixes #976.
Jordan Harband 2016-02-15 09:17:24 -08:00
commit cf7d5d8042
2 changed files with 24 additions and 13 deletions

32
nvm.sh
View File

@ -2377,7 +2377,8 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
nvm_print_npm_version nvm_npm_global_modules \ nvm_print_npm_version nvm_npm_global_modules \
nvm_has_system_node nvm_has_system_iojs \ nvm_has_system_node nvm_has_system_iojs \
nvm_download nvm_get_latest nvm_has nvm_get_latest \ nvm_download nvm_get_latest nvm_has nvm_get_latest \
nvm_supports_source_options nvm_auto nvm_supports_xz > /dev/null 2>&1 nvm_supports_source_options nvm_auto nvm_supports_xz \
nvm_process_parameters > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1 unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;; ;;
* ) * )
@ -2419,17 +2420,22 @@ nvm_auto() {
fi fi
} }
NVM_AUTO_MODE='use' nvm_process_parameters() {
if nvm_supports_source_options; then local NVM_AUTO_MODE
while [ $# -ne 0 ] NVM_AUTO_MODE='use'
do if nvm_supports_source_options; then
case "$1" in while [ $# -ne 0 ]
--install) NVM_AUTO_MODE='install' ;; do
--no-use) NVM_AUTO_MODE='none' ;; case "$1" in
esac --install) NVM_AUTO_MODE='install' ;;
shift --no-use) NVM_AUTO_MODE='none' ;;
done esac
fi shift
nvm_auto "$NVM_AUTO_MODE" done
fi
nvm_auto "$NVM_AUTO_MODE"
}
nvm_process_parameters "$@"
} # this ensures the entire script is downloaded # } # this ensures the entire script is downloaded #

View File

@ -0,0 +1,5 @@
#!/bin/sh
set -- yes
. ../../nvm.sh
[ "$1" = yes ]