[Fix] `nvm_normalize_lts`: switch from expr to case

avoids `expr: warning: ^lts/-[1-9][0-9]*: using ^ as the first character of a basic regular expression is not portable; it is ignored`
Jordan Harband 2023-11-01 12:24:29 -07:00
parent 6743aef70c
commit 1f970ccb7a
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 25 additions and 17 deletions

14
nvm.sh
View File

@ -756,10 +756,16 @@ nvm_normalize_lts() {
local LTS local LTS
LTS="${1-}" LTS="${1-}"
if [ "$(expr "${LTS}" : '^lts/-[1-9][0-9]*$')" -gt 0 ]; then case "${LTS}" in
lts/-[123456789] | lts/-[123456789][0123456789]*)
local N local N
N="$(echo "${LTS}" | cut -d '-' -f 2)" N="$(echo "${LTS}" | cut -d '-' -f 2)"
N=$((N+1)) N=$((N+1))
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
nvm_echo "${LTS}"
return 0
fi
local NVM_ALIAS_DIR local NVM_ALIAS_DIR
NVM_ALIAS_DIR="$(nvm_alias_path)" NVM_ALIAS_DIR="$(nvm_alias_path)"
local RESULT local RESULT
@ -770,9 +776,11 @@ nvm_normalize_lts() {
nvm_err 'That many LTS releases do not exist yet.' nvm_err 'That many LTS releases do not exist yet.'
return 2 return 2
fi fi
else ;;
*)
nvm_echo "${LTS}" nvm_echo "${LTS}"
fi ;;
esac
} }
nvm_ensure_version_prefix() { nvm_ensure_version_prefix() {