[Fix] ensure if `npm link` fails, that `$IFS` is not improperly set.

https://github.com/creationix/nvm/issues/1519#issuecomment-297850323
Jordan Harband 2017-04-28 00:39:48 -07:00
parent caa7de37af
commit accd6ae298
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 9 additions and 8 deletions

17
nvm.sh
View File

@ -3157,15 +3157,16 @@ nvm() {
nvm_echo "$INSTALLS" | command xargs npm install -g --quiet
nvm_echo "Linking global packages from $VERSION..."
set -f; IFS='
(
set -f; IFS='
' # necessary to turn off variable expansion except for newlines
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(nvm_cd "$LINK" && npm link)
fi
done
set +f; unset IFS # restore variable expansion in case $LINKS was empty
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(nvm_cd "$LINK" && npm link)
fi
done
)
;;
"clear-cache" )
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null