diff --git a/nvm.sh b/nvm.sh index 8ac13ea..88bf290 100644 --- a/nvm.sh +++ b/nvm.sh @@ -130,7 +130,9 @@ nvm_ls() { fi # If it looks like an explicit version, don't do anything funny if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then - VERSIONS="$PATTERN" + if [ -d "$NVM_DIR/$PATTERN" ]; then + VERSIONS="$PATTERN" + fi else VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \ | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | grep -v '^ *\.'` diff --git "a/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" "b/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" new file mode 100755 index 0000000..7cd94ce --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" @@ -0,0 +1,10 @@ +#!/bin/sh + +mkdir ../../../v0.1.2 + +. ../../../nvm.sh + +nvm ls v0.1 | grep v0.1.2 && +nvm ls v0.1.2 | grep v0.1.2 && +nvm ls v0.1. | grep N/A && +nvm ls v0.1.1 | grep N/A