Fixing `nvm ls 0.x` to only include `0.x.*` instead of `0.x*.*`

master
Jordan Harband 2014-07-09 01:19:48 -07:00
parent 802f064178
commit 4cfe62d3d1
1 changed files with 5 additions and 1 deletions

6
nvm.sh
View File

@ -158,7 +158,11 @@ nvm_ls() {
VERSIONS="$PATTERN" VERSIONS="$PATTERN"
fi fi
else else
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \ PATTERN=$(nvm_format_version $PATTERN)
if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
PATTERN="$PATTERN."
fi
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.'` | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.'`
fi fi
if [ -z "$VERSIONS" ]; then if [ -z "$VERSIONS" ]; then