`nvm_num_version_groups` should report 0 when given just a v or a .

master
Jordan Harband 2015-04-06 11:10:43 -07:00
parent 3d764e6833
commit c34502ebc2
2 changed files with 6 additions and 2 deletions

4
nvm.sh
View File

@ -333,12 +333,12 @@ nvm_format_version() {
nvm_num_version_groups() {
local VERSION
VERSION="$1"
VERSION="${VERSION#v}"
VERSION="${VERSION%.}"
if [ -z "$VERSION" ]; then
echo "0"
return
fi
VERSION="${VERSION#v*}"
VERSION="${VERSION%\.}"
local NVM_NUM_DOTS
NVM_NUM_DOTS=$(echo "$VERSION" | command sed -e 's/[^\.]//g')
local NVM_NUM_GROUPS

View File

@ -5,13 +5,17 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"
[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." should give 0"
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
[ "~$(nvm_num_version_groups 1.)" = "~1" ] || die "1. should give 1"
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
[ "~$(nvm_num_version_groups 1.2.)" = "~2" ] || die "1.2. should give 2"
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"