avoid nullglob in alias command

master
Fraser Tweedale 2014-02-22 00:00:10 +10:00
parent 1d6145de5a
commit 8cba9c5781
1 changed files with 3 additions and 11 deletions

14
nvm.sh
View File

@ -34,16 +34,6 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist" export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi fi
nvm_set_nullglob() {
if has "setopt"; then
# Zsh
setopt NULL_GLOB
elif has "shopt"; then
# Bash
shopt -s nullglob
fi
}
# Obtain nvm version from rc file # Obtain nvm version from rc file
rc_nvm_version() { rc_nvm_version() {
if [ -e .nvmrc ]; then if [ -e .nvmrc ]; then
@ -491,7 +481,8 @@ nvm() {
mkdir -p $NVM_DIR/alias mkdir -p $NVM_DIR/alias
if [ $# -le 2 ]; then if [ $# -le 2 ]; then
local DEST local DEST
for ALIAS in $(nvm_set_nullglob; echo $NVM_DIR/alias/$2* ); do for ALIAS in $NVM_DIR/alias/$2*; do
if [ -e "$ALIAS" ]; then
DEST=`cat $ALIAS` DEST=`cat $ALIAS`
VERSION=`nvm_version $DEST` VERSION=`nvm_version $DEST`
if [ "$DEST" = "$VERSION" ]; then if [ "$DEST" = "$VERSION" ]; then
@ -499,6 +490,7 @@ nvm() {
else else
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)" echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
fi fi
fi
done done
return return
fi fi