Skip to content
Myr

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

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

avoids `expr: warning: ^lts/-[1-9][0-9]*: using ^ as the first character of a basic regular expression is not portable; it is ignored`

authored by Jordan Harband · committed by Jordan Harband · parent 6743aef · Browse files · 1 file+25 added−17 removed
This commit

State

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

Diff stats

1 file+25 added−17 removed

  • other:+25 added−17 removed

1 file+25 added−17 removed

modified:nvm.sh+25 added-17 removed
754 unmodified lines
755nvm_normalize_lts() {756 local LTS757 LTS="${1-}"758759 case "${LTS}" in760 lts/-[123456789] | lts/-[123456789][0123456789]*)761 local N762 N="$(echo "${LTS}" | cut -d '-' -f 2)"763 N=$((N+1))764 # shellcheck disable=SC2181759 if [ "$(expr "${LTS}" : '^lts/-[1-9][0-9]*$')" -gt 0 ]; then760 local N761 N="$(echo "${LTS}" | cut -d '-' -f 2)"762 N=$((N+1))763 local NVM_ALIAS_DIR764 NVM_ALIAS_DIR="$(nvm_alias_path)"765 local RESULT766 RESULT="$(command ls "${NVM_ALIAS_DIR}/lts" | command tail -n "${N}" | command head -n 1)"767 if [ "${RESULT}" != '*' ]; then768 nvm_echo "lts/${RESULT}"769 else770 nvm_err 'That many LTS releases do not exist yet.'771 return 2772 fi773 else774 nvm_echo "${LTS}"775 fi765 if [ $? -ne 0 ]; then766 nvm_echo "${LTS}"767 return 0768 fi769 local NVM_ALIAS_DIR770 NVM_ALIAS_DIR="$(nvm_alias_path)"771 local RESULT772 RESULT="$(command ls "${NVM_ALIAS_DIR}/lts" | command tail -n "${N}" | command head -n 1)"773 if [ "${RESULT}" != '*' ]; then774 nvm_echo "lts/${RESULT}"775 else776 nvm_err 'That many LTS releases do not exist yet.'777 return 2778 fi779 ;;780 *)781 nvm_echo "${LTS}"782 ;;783 esac784}785786nvm_ensure_version_prefix() {787 local NVM_VERSION
3640 unmodified lines