[Fix] zsh: restore nomatch and markdirs rather than clobbering them

`unsetopt local_options nomatch` unsets both named options,
so LOCAL_OPTIONS is off by the time the function returns and the
`nomatch` change escapes into the caller's shell:
one `nvm ls` or `nvm alias` leaves NO_MATCH off for the rest of the session,
after which an unmatched glob is silently passed through as a literal.

`setopt local_options nonomatch`,
already used in `nvm_check_file_permissions`, restores on return.

The `markdirs` line also cancelled the snapshot
taken for `shwordsplit` on the line above it;
that one is latent,
as `nvm_ls` is only ever called inside a command substitution.
This commit is contained in:
Jordan Harband
2026-09-03 20:44:59 -07:00
parent 3a72926f4a
commit 25b378323c
2 changed files with 56 additions and 2 deletions
+2 -2
View File
@@ -1389,7 +1389,7 @@ nvm_list_aliases() {
NVM_HAS_COLORS=1
fi
nvm_is_zsh && unsetopt local_options nomatch
nvm_is_zsh && setopt local_options nonomatch
(
local ALIAS_PATH
for ALIAS_PATH in "${NVM_ALIAS_DIR}/${ALIAS}"*; do
@@ -1685,7 +1685,7 @@ nvm_ls() {
esac
nvm_is_zsh && setopt local_options shwordsplit
nvm_is_zsh && unsetopt local_options markdirs
nvm_is_zsh && setopt local_options nomarkdirs
local NVM_DIRS_TO_SEARCH1
NVM_DIRS_TO_SEARCH1=''