Skip to content

Commit cf7d5d8

Browse files
committed
Merge pull request #1011 from dohse/keep-parameters
[Fix] Do not modify args of sourcing script when parsing `--install`/`--no-use` arg Fixes #976.
2 parents dc9020b + 7135873 commit cf7d5d8

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

nvm.sh

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,8 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
23772377
nvm_print_npm_version nvm_npm_global_modules \
23782378
nvm_has_system_node nvm_has_system_iojs \
23792379
nvm_download nvm_get_latest nvm_has nvm_get_latest \
2380-
nvm_supports_source_options nvm_auto nvm_supports_xz > /dev/null 2>&1
2380+
nvm_supports_source_options nvm_auto nvm_supports_xz \
2381+
nvm_process_parameters > /dev/null 2>&1
23812382
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
23822383
;;
23832384
* )
@@ -2419,17 +2420,22 @@ nvm_auto() {
24192420
fi
24202421
}
24212422

2422-
NVM_AUTO_MODE='use'
2423-
if nvm_supports_source_options; then
2424-
while [ $# -ne 0 ]
2425-
do
2426-
case "$1" in
2427-
--install) NVM_AUTO_MODE='install' ;;
2428-
--no-use) NVM_AUTO_MODE='none' ;;
2429-
esac
2430-
shift
2431-
done
2432-
fi
2433-
nvm_auto "$NVM_AUTO_MODE"
2423+
nvm_process_parameters() {
2424+
local NVM_AUTO_MODE
2425+
NVM_AUTO_MODE='use'
2426+
if nvm_supports_source_options; then
2427+
while [ $# -ne 0 ]
2428+
do
2429+
case "$1" in
2430+
--install) NVM_AUTO_MODE='install' ;;
2431+
--no-use) NVM_AUTO_MODE='none' ;;
2432+
esac
2433+
shift
2434+
done
2435+
fi
2436+
nvm_auto "$NVM_AUTO_MODE"
2437+
}
2438+
2439+
nvm_process_parameters "$@"
24342440

24352441
} # this ensures the entire script is downloaded #
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -- yes
4+
. ../../nvm.sh
5+
[ "$1" = yes ]

0 commit comments

Comments
 (0)