Skip to content
Myr

[Fix] `nvm_strip_path`: avoid gawk-specific `RT` variable for mawk compatibility

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 38ffc71 · Browse files · 1 file+8 added−3 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+8 added−3 removed

  • other:+8 added−3 removed

1 file+8 added−3 removed

modified:nvm.sh+8 added-3 removed
976 unmodified lines
977 if [ -z "${NVM_DIR-}" ]; then978 nvm_err '${NVM_DIR} not set!'979 return 1980 fi981 local RESULT981 command printf %s "${1-}" | command awk -v NVM_DIR="${NVM_DIR}" -v RS=: '982 RESULT="$(command printf %s "${1-}" | command awk -v NVM_DIR="${NVM_DIR}" -v RS=: '983 index($0, NVM_DIR) == 1 {984 path = substr($0, length(NVM_DIR) + 1)985 if (path ~ "^(/versions/[^/]*)?/[^/]*'"${2-}"'.*$") { next }986 }986 # The final RT will contain a colon if the input has a trailing colon, or a null string otherwise987 { printf "%s%s", sep, $0; sep=RS } END { printf "%s", RT }'987 { printf "%s%s", sep, $0; sep=RS }')"988 # mawk does not support RT, so preserve trailing colon manually989 case "${1-}" in990 *:) command printf '%s:' "${RESULT}" ;;991 *) command printf '%s' "${RESULT}" ;;992 esac993}994995nvm_change_path() {996 # if there’s no initial path, just return the supplementary path
3686 unmodified lines