From 96069da0d5401e8e5008e404f6873b21f32f7937 Mon Sep 17 00:00:00 2001 From: Dylan Armstrong Date: Fri, 9 Oct 2020 09:43:21 -0500 Subject: [PATCH] [Fix] `nvm_ls`: zsh: unset `markdirs` and `local_options` Fixes #2315. --- nvm.sh | 1 + ...nvm ls\" should not show a trailing slash" | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 "test/fast/Listing versions/Running \"nvm ls\" should not show a trailing slash" diff --git a/nvm.sh b/nvm.sh index 995cb74..505c7ff 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1089,6 +1089,7 @@ nvm_ls() { esac nvm_is_zsh && setopt local_options shwordsplit + nvm_is_zsh && unsetopt local_options markdirs local NVM_DIRS_TO_SEARCH1 NVM_DIRS_TO_SEARCH1='' diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should not show a trailing slash" "b/test/fast/Listing versions/Running \"nvm ls\" should not show a trailing slash" new file mode 100755 index 0000000..5173870 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should not show a trailing slash" @@ -0,0 +1,40 @@ +#!/bin/zsh + +\. ../../../nvm.sh +\. ../../common.sh + +if type setopt >/dev/null 2>&1; then setopt local_options markdirs; fi + +die () { + if type unsetopt >/dev/null 2>&1; then unsetopt local_options markdirs; fi + echo "$@"; + exit 1; +} + +make_fake_node v0.0.1 +make_fake_node v0.0.3 +make_fake_node v0.0.9 +make_fake_node v0.3.1 +make_fake_node v0.3.3 +make_fake_node v0.3.9 +make_fake_node v0.12.87 +make_fake_node v0.12.9 +make_fake_iojs v0.1.2 +make_fake_iojs v0.10.2 + +OUTPUT="$(nvm_ls)" +EXPECTED_OUTPUT="v0.0.1 +v0.0.3 +v0.0.9 +iojs-v0.1.2 +v0.3.1 +v0.3.3 +v0.3.9 +iojs-v0.10.2 +v0.12.9 +v0.12.87" +if nvm_has_system_node || nvm_has_system_iojs; then + EXPECTED_OUTPUT="${EXPECTED_OUTPUT} +system" +fi +[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"