File tree 1 file changed +25
-17
lines changed
1 file changed +25
-17
lines changed Original file line number Diff line number Diff line change @@ -756,23 +756,31 @@ nvm_normalize_lts() {
756
756
local LTS
757
757
LTS=" ${1-} "
758
758
759
- if [ " $( expr " ${LTS} " : ' ^lts/-[1-9][0-9]*$' ) " -gt 0 ]; then
760
- local N
761
- N=" $( echo " ${LTS} " | cut -d ' -' -f 2) "
762
- N=$(( N+ 1 ))
763
- local NVM_ALIAS_DIR
764
- NVM_ALIAS_DIR=" $( nvm_alias_path) "
765
- local RESULT
766
- RESULT=" $( command ls " ${NVM_ALIAS_DIR} /lts" | command tail -n " ${N} " | command head -n 1) "
767
- if [ " ${RESULT} " != ' *' ]; then
768
- nvm_echo " lts/${RESULT} "
769
- else
770
- nvm_err ' That many LTS releases do not exist yet.'
771
- return 2
772
- fi
773
- else
774
- nvm_echo " ${LTS} "
775
- fi
759
+ case " ${LTS} " in
760
+ lts/-[123456789] | lts/-[123456789][0123456789]* )
761
+ local N
762
+ N=" $( echo " ${LTS} " | cut -d ' -' -f 2) "
763
+ ( N=$(( N+ 1 )) ; ) 2> /dev/null
764
+ # shellcheck disable=SC2181
765
+ if [ $? -ne 0 ]; then
766
+ nvm_echo " ${LTS} "
767
+ return 0
768
+ fi
769
+ local NVM_ALIAS_DIR
770
+ NVM_ALIAS_DIR=" $( nvm_alias_path) "
771
+ local RESULT
772
+ RESULT=" $( command ls " ${NVM_ALIAS_DIR} /lts" | command tail -n " ${N} " | command head -n 1) "
773
+ if [ " ${RESULT} " != ' *' ]; then
774
+ nvm_echo " lts/${RESULT} "
775
+ else
776
+ nvm_err ' That many LTS releases do not exist yet.'
777
+ return 2
778
+ fi
779
+ ;;
780
+ * )
781
+ nvm_echo " ${LTS} "
782
+ ;;
783
+ esac
776
784
}
777
785
778
786
nvm_ensure_version_prefix () {
You can’t perform that action at this time.
0 commit comments