nvm alias: explicitly forbid user aliases in subdirs.

This commit is contained in:
Jordan Harband
2016-04-26 23:07:10 -07:00
parent 1eb4d482e0
commit 677c69dda0
3 changed files with 62 additions and 0 deletions

8
nvm.sh
View File

@@ -2318,6 +2318,10 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
nvm unalias "${2-}"
return $?
fi
if [ "${2#*\/}" != "${2-}" ]; then
>&2 echo "Aliases in subdirectories are not supported."
return 1
fi
VERSION="$(nvm_version "${3-}")"
if [ $? -ne 0 ]; then
echo "! WARNING: Version '${3-}' does not exist." >&2
@@ -2337,6 +2341,10 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
>&2 nvm help
return 127
fi
if [ "${2#*\/}" != "${2-}" ]; then
>&2 echo "Aliases in subdirectories are not supported."
return 1
fi
[ ! -f "$NVM_ALIAS_DIR/$2" ] && echo "Alias $2 doesn't exist!" >&2 && return
local NVM_ALIAS_ORIGINAL
NVM_ALIAS_ORIGINAL="$(nvm_alias "$2")"