Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
    return 0
  fi
  return 1
}

nvm_windows_drive_posix() {
  nvm_grep -iEe "^$1 " /proc/mounts 2>/dev/null | command awk '{ print $2 }'
}

# args: path to check and transform if needed
nvm_ensure_posix_path() {
  if [ -z "${1-}" ]; then
    nvm_err "Need the location as first parameter"
    return 1
  fi
  local location
  location="$1"

  # If already posix path, just return it
  if [ "$(command printf '%s' "$location" | command cut -b 1)" = "/" ]; then
    nvm_echo "$location"
    return 0
  fi

  # If absolute path (eg. starting with C:)
  if command printf '%s' "$location" | command grep '^[a-zA-Z]:' >/dev/null 2>&1; then
    # Get drive letter, eg. C:
    local drive
    drive=$(command printf '%s' "$location" | command cut -b -2)
    local prefix
    prefix=$(nvm_windows_drive_posix "$drive")

    if [ -z "${prefix:-}" ]; then
      nvm_err "Unable to find where '$drive' is mounted"
      return 1
    fi

    # Remove drive letter prefix (eg. C:)
    location=$(command printf '%s' "$location" | command cut -b 3-)
    # Set prefix
    location="${prefix}${location}"
  fi

  # Replace \ by /
  location=$(command printf '%s' "$location" | command sed 's#\\#/#g')
  nvm_echo "${location}"
}

nvm_die_on_prefix() {
  local NVM_DELETE_PREFIX
  NVM_DELETE_PREFIX="${1-}"

Review comment (suggestion):
```suggestion
  if command printf '%s' "$location" | nvm_grep '^[a-zA-Z]:' >/dev/null 2>&1; then
```

Code after:

nvm_npm_global_modules() {
  local NPMLIST
  local VERSION
  VERSION="$1"
  NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY')

  local INSTALLS
  INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)

  local LINKS
  LINKS="$(nvm_echo "${NPMLIST}" | command sed -n 's/.* -> \(.*\)/\1/ p')"

  nvm_echo "${INSTALLS} //// ${LINKS}"
}

nvm_npmrc_bad_news_bears() {
  local NVM_NPMRC
  NVM_NPMRC="${1-}"
  if [ -n "${NVM_NPMRC}" ] && [ -f "${NVM_NPMRC}" ] && nvm_grep -Ee '^(prefix|globalconfig) *=' <"${NVM_NPMRC}" >/dev/null; then
    return 0
  fi
  return 1
}

nvm_die_on_prefix() {
  local NVM_DELETE_PREFIX
  NVM_DELETE_PREFIX="${1-}"
  case "${NVM_DELETE_PREFIX}" in
    0 | 1) ;;
    *)
      nvm_err 'First argument "delete the prefix" must be zero or one'
      return 1
    ;;
  esac
  local NVM_COMMAND
  NVM_COMMAND="${2-}"
  local NVM_VERSION_DIR
  NVM_VERSION_DIR="${3-}"
  if [ -z "${NVM_COMMAND}" ] || [ -z "${NVM_VERSION_DIR}" ]; then
    nvm_err 'Second argument "nvm command", and third argument "nvm version dir", must both be nonempty'
    return 2
  fi

  # npm first looks at $PREFIX (case-sensitive)
  # we do not bother to test the value here; if this env var is set, unset it to continue.
  # however, `npm exec` in npm v7.2+ sets $PREFIX; if set, inherit it
  if [ -n "${PREFIX-}" ] && [ "$(nvm_version_path "$(node -v)")" != "${PREFIX}" ]; then
    nvm deactivate >/dev/null 2>&1
    nvm_err "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"${PREFIX}\""
    nvm_err 'Run `unset PREFIX` to unset it.'