Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent 3d764e6 · Browse files · 2 files+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−2 removed

  • tests:+4 added−0 removed
  • other:+2 added−2 removed

2 files+6 added−2 removed

modified:test/fast/Unit tests/nvm_num_version_groups+4 added
3 unmodified lines
45. ../../../nvm.sh67[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"8[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"9[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." should give 0"10[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"1112[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"13[ "~$(nvm_num_version_groups 1.)" = "~1" ] || die "1. should give 1"14[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"15[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"1617[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"18[ "~$(nvm_num_version_groups 1.2.)" = "~2" ] || die "1.2. should give 2"19[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"20[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"2122[ "~$(nvm_num_version_groups 1.2.3)" = "~3" ] || die "1.2.3 should give 3"
3 unmodified lines
modified:nvm.sh+2 added-2 removed
331 unmodified lines
332333nvm_num_version_groups() {334 local VERSION335 VERSION="$1"336 VERSION="${VERSION#v}"337 VERSION="${VERSION%.}"338 if [ -z "$VERSION" ]; then339 echo "0"340 return341 fi340 VERSION="${VERSION#v*}"341 VERSION="${VERSION%\.}"342 local NVM_NUM_DOTS343 NVM_NUM_DOTS=$(echo "$VERSION" | command sed -e 's/[^\.]//g')344 local NVM_NUM_GROUPS345 NVM_NUM_GROUPS=".$NVM_NUM_DOTS" # add extra dot, since it's (n - 1) dots at this point
1415 unmodified lines