[Fix] `nvm uninstall`: work around `nomatch` `zsh` option.
Fixes #1228.
parent
a29d0e49dc
commit
f9e14b7d4d
15
nvm.sh
15
nvm.sh
|
@ -2041,16 +2041,31 @@ nvm_is_natural_num() {
|
||||||
|
|
||||||
# Check version dir permissions
|
# Check version dir permissions
|
||||||
nvm_check_file_permissions() {
|
nvm_check_file_permissions() {
|
||||||
|
local ZSH_HAS_NONOMATCH_UNSET
|
||||||
|
ZSH_HAS_NONOMATCH_UNSET=1
|
||||||
|
if nvm_has "setopt"; then
|
||||||
|
ZSH_HAS_NONOMATCH_UNSET="$(set +e ; setopt | nvm_grep nonomatch > /dev/null ; nvm_echo $?)"
|
||||||
|
setopt nonomatch
|
||||||
|
fi
|
||||||
for FILE in $1/* $1/.[!.]* $1/..?* ; do
|
for FILE in $1/* $1/.[!.]* $1/..?* ; do
|
||||||
if [ -d "$FILE" ]; then
|
if [ -d "$FILE" ]; then
|
||||||
if ! nvm_check_file_permissions "$FILE"; then
|
if ! nvm_check_file_permissions "$FILE"; then
|
||||||
|
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
|
||||||
|
setopt nomatch
|
||||||
|
fi
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
elif [ -e "$FILE" ] && [ ! -w "$FILE" ]; then
|
elif [ -e "$FILE" ] && [ ! -w "$FILE" ]; then
|
||||||
nvm_err "file is not writable: $(nvm_sanitize_path "$FILE")"
|
nvm_err "file is not writable: $(nvm_sanitize_path "$FILE")"
|
||||||
|
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
|
||||||
|
setopt nomatch
|
||||||
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then
|
||||||
|
setopt nomatch
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,11 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
|
||||||
# Switch to another version so we can uninstall
|
# Switch to another version so we can uninstall
|
||||||
nvm use 0.12.7
|
nvm use 0.12.7
|
||||||
|
|
||||||
|
# if zsh, set "nomatch" opt to reproduce failure from https://github.com/creationix/nvm/issues/1228
|
||||||
|
if nvm_has "setopt"; then
|
||||||
|
setopt nomatch
|
||||||
|
fi
|
||||||
|
|
||||||
# Uninstall it
|
# Uninstall it
|
||||||
nvm uninstall $NVM_TEST_VERSION
|
nvm uninstall $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue