From c992b1766c2a4277a164450d1568e9acffbccebb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 16 Sep 2014 08:36:40 -0700 Subject: [PATCH] Use `nvm_num_version_groups` in `nvm_ls` --- nvm.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index 8bca98c..0e2a8a0 100644 --- a/nvm.sh +++ b/nvm.sh @@ -247,14 +247,18 @@ nvm_ls() { return fi # If it looks like an explicit version, don't do anything funny - if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then + if [ "~$(echo "$PATTERN" | cut -c1-1)" = "~v" ] && [ "~$(nvm_num_version_groups "$PATTERN")" = "~3" ]; then if [ -d "$(nvm_version_path "$PATTERN")" ]; then VERSIONS="$PATTERN" fi else PATTERN=$(nvm_format_version $PATTERN) - if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then - PATTERN="$PATTERN." + if [ "~$PATTERN" != "~system" ]; then + local NUM_VERSION_GROUPS + NUM_VERSION_GROUPS="$(nvm_num_version_groups "$PATTERN")" + if [ "~$NUM_VERSION_GROUPS" = "~2" ] || [ "~$NUM_VERSION_GROUPS" = "~1" ]; then + PATTERN="$(echo "$PATTERN" | sed -e 's/\.*$//g')." + fi fi if [ -d "$(nvm_version_dir new)" ]; then VERSIONS=`find "$(nvm_version_dir new)/" "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \