ronantakizawa/codereview-bench huggingface dataset:
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:

# Traverse up in directory tree to find containing folder
nvm_find_up() {
  local path_
  path_="${PWD}"
  while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
    path_=${path_%/*}
  done
  nvm_echo "${path_}"
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain the nvm version from the .nvmrc file
nvm_rc_version() {
  # Check if quiet mode is on
  local quiet="false"
  if [ "$1" == "--silent" ]; then
    quiet="true"
  fi
  # Set NVM_RC_VERSION to null before we set it ourselves
  export NVM_RC_VERSION=''
  # Check where .nvmrc exists
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  # Give an error if the .nvmrc doesn't exist
  if [ ! -e "${NVMRC_PATH}" ]; then
    # Give an error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  # Read the .nvmrc file
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  # Check if .nvmrc is empty
  if [ -z "${NVM_RC_VERSION}" ]; then
    # Give error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  # Echo the contents of .nvmrc and where it was found if quiet mode is off
  if [ "$quiet" == "false" ]; then

Review comment (suggestion):
```suggestion
  local NVM_USE_SILENT
  NVM_USE_SILENT=false
  if [ "${1-}" = '--silent' ]; then
    NVM_USE_SILENT=true
  fi
```
due to ksh, all variables must be declared on one line with `local`, and then assigned on a separate line.

additionally, variable names should be prefixed with NVM_ so that in ksh, they won't clobber user shell vars.
(also, `==` only works in bash/zsh)

Code after:

# Traverse up in directory tree to find containing folder
nvm_find_up() {
  local path_
  path_="${PWD}"
  while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
    path_=${path_%/*}
  done
  nvm_echo "${path_}"
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain nvm version from rc file
nvm_rc_version() {
  export NVM_RC_VERSION=''
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  if [ ! -e "${NVMRC_PATH}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  if [ -z "${NVM_RC_VERSION}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  if [ "${NVM_SILENT:-0}" -ne 1 ]; then
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
  fi
}

nvm_clang_version() {
  clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
}

nvm_curl_version() {
  curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
}

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

Code before:
# Traverse up in directory tree to find containing folder
nvm_find_up() {
  local path_
  path_="${PWD}"
  while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
    path_=${path_%/*}
  done
  nvm_echo "${path_}"
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain the nvm version from the .nvmrc file
nvm_rc_version() {
  # Check if quiet mode is on
  local quiet="false"
  if [ "$1" == "--silent" ]; then
    quiet="true"
  fi
  # Set NVM_RC_VERSION to null before we set it ourselves
  export NVM_RC_VERSION=''
  # Check where .nvmrc exists
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  # Give an error if the .nvmrc doesn't exist
  if [ ! -e "${NVMRC_PATH}" ]; then
    # Give an error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  # Read the .nvmrc file
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  # Check if .nvmrc is empty
  if [ -z "${NVM_RC_VERSION}" ]; then
    # Give error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  # Echo the contents of .nvmrc and where it was found if quiet mode is off
  if [ "$quiet" == "false" ]; then
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"

Review comment (suggestion):
we don't need all these comments; a comment that explains what the next line is doing verbatim isn't helping the code be readable :-)
```suggestion
```

Code after:
# Traverse up in directory tree to find containing folder
nvm_find_up() {
  local path_
  path_="${PWD}"
  while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
    path_=${path_%/*}
  done
  nvm_echo "${path_}"
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain nvm version from rc file
nvm_rc_version() {
  export NVM_RC_VERSION=''
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  if [ ! -e "${NVMRC_PATH}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  if [ -z "${NVM_RC_VERSION}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  if [ "${NVM_SILENT:-0}" -ne 1 ]; then
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
  fi
}

nvm_clang_version() {
  clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
}

nvm_curl_version() {
  curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
}

nvm_version_greater() {
  command awk 'BEGIN {
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain the nvm version from the .nvmrc file
nvm_rc_version() {
  # Check if quiet mode is on
  local quiet="false"
  if [ "$1" == "--silent" ]; then
    quiet="true"
  fi
  # Set NVM_RC_VERSION to null before we set it ourselves
  export NVM_RC_VERSION=''
  # Check where .nvmrc exists
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  # Give an error if the .nvmrc doesn't exist
  if [ ! -e "${NVMRC_PATH}" ]; then
    # Give an error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  # Read the .nvmrc file
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  # Check if .nvmrc is empty
  if [ -z "${NVM_RC_VERSION}" ]; then
    # Give error only if quiet mode is off
    if [ "$quiet" == "false" ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  # Echo the contents of .nvmrc and where it was found if quiet mode is off
  if [ "$quiet" == "false" ]; then
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
  fi
}

nvm_clang_version() {
  clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
}

nvm_curl_version() {

Review comment (suggestion):
```suggestion
    if [ "${NVM_USE_SILENT}" != true ]; then
```

Code after:
}

nvm_find_nvmrc() {
  local dir
  dir="$(nvm_find_up '.nvmrc')"
  if [ -e "${dir}/.nvmrc" ]; then
    nvm_echo "${dir}/.nvmrc"
  fi
}

# Obtain nvm version from rc file
nvm_rc_version() {
  export NVM_RC_VERSION=''
  local NVMRC_PATH
  NVMRC_PATH="$(nvm_find_nvmrc)"
  if [ ! -e "${NVMRC_PATH}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "No .nvmrc file found"
    fi
    return 1
  fi
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
  if [ -z "${NVM_RC_VERSION}" ]; then
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
      nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
    fi
    return 2
  fi
  if [ "${NVM_SILENT:-0}" -ne 1 ]; then
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
  fi
}

nvm_clang_version() {
  clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'
}

nvm_curl_version() {
  curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
}

nvm_version_greater() {
  command awk 'BEGIN {
    if (ARGV[1] == "" || ARGV[2] == "") exit(1)
    split(ARGV[1], a, /\./);
    split(ARGV[2], b, /\./);
    for (i=1; i<=3; i++) {
      if (a[i] && a[i] !~ /^[0-9]+$/) exit(2);
      if (b[i] && b[i] !~ /^[0-9]+$/) { exit(0); }
      if (a[i] < b[i]) exit(3);
      else if (a[i] > b[i]) exit(0);
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
        fi
      fi

      if [ -n "${NODE_PATH-}" ]; then
        NEWPATH="$(nvm_strip_path "${NODE_PATH}" "/lib/node_modules")"
        if [ "_${NODE_PATH}" != "_${NEWPATH}" ]; then
          export NODE_PATH="${NEWPATH}"
          if [ "$NVM_USE_SILENT" -ne 1 ]; then
            nvm_echo "${NVM_DIR}/*/lib/node_modules removed from \${NODE_PATH}"
          fi
        fi
      fi
      unset NVM_BIN
      unset NVM_INC
    ;;
    "use")
      local PROVIDED_VERSION
      local NVM_USE_SILENT
      NVM_USE_SILENT=0
      local NVM_DELETE_PREFIX
      NVM_DELETE_PREFIX=0
      local NVM_LTS

      while [ $# -ne 0 ]; do
        case "$1" in
          "--silent") NVM_USE_SILENT=1 ;;
          --delete-prefix) NVM_DELETE_PREFIX=1 ;;
          --) ;;
          --lts) NVM_LTS='*' ;;
          --lts=*) NVM_LTS="${1##--lts=}" ;;
          --*) ;;
          *)
            if [ -n "${1-}" ]; then
              PROVIDED_VERSION="$1"
            fi
          ;;
        esac
        shift
      done

      if [ -n "${NVM_LTS-}" ]; then
        VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"
      elif [ -z "${PROVIDED_VERSION-}" ]; then
        # Get the .nvmrc version depending if quiet mode is on or not
        if [ $NVM_USE_SILENT -ne 1 ]; then
          nvm_rc_version
        else
          nvm_rc_version --silent
        fi
        if [ -n "${NVM_RC_VERSION-}" ]; then
          PROVIDED_VERSION="${NVM_RC_VERSION}"

Review comment (suggestion):
```suggestion
          --silent) NVM_USE_SILENT=1 ;;
```
the quotes are unnecessary.

Code after:
          if [ "${NVM_SILENT:-0}" -ne 1 ]; then
            nvm_echo "${NVM_DIR}/*/lib/node_modules removed from \${NODE_PATH}"
          fi
        fi
      fi
      unset NVM_BIN
      unset NVM_INC
    ;;
    "use")
      local PROVIDED_VERSION
      local NVM_SILENT
      local NVM_SILENT_ARG
      local NVM_DELETE_PREFIX
      NVM_DELETE_PREFIX=0
      local NVM_LTS

      while [ $# -ne 0 ]; do
        case "$1" in
          --silent)
            NVM_SILENT=1
            NVM_SILENT_ARG='--silent'
          ;;
          --delete-prefix) NVM_DELETE_PREFIX=1 ;;
          --) ;;
          --lts) NVM_LTS='*' ;;
          --lts=*) NVM_LTS="${1##--lts=}" ;;
          --*) ;;
          *)
            if [ -n "${1-}" ]; then
              PROVIDED_VERSION="$1"
            fi
          ;;
        esac
        shift
      done

      if [ -n "${NVM_LTS-}" ]; then
        VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"
      elif [ -z "${PROVIDED_VERSION-}" ]; then
        NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version
        if [ -n "${NVM_RC_VERSION-}" ]; then
          PROVIDED_VERSION="${NVM_RC_VERSION}"
          VERSION="$(nvm_version "${PROVIDED_VERSION}")"
        fi
        unset NVM_RC_VERSION
        if [ -z "${VERSION}" ]; then
          nvm_err 'Please see `nvm --help` or https://github.com/nvm-sh/nvm#nvmrc for more information.'
          return 127
        fi
      else
        VERSION="$(nvm_match_version "${PROVIDED_VERSION}")"
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:

  local TARBALL
  local TMPDIR
  local VERSION_PATH

  local PROGRESS_BAR
  local NODE_OR_IOJS
  if [ "${FLAVOR}" = 'node' ]; then
    NODE_OR_IOJS="${FLAVOR}"
  elif [ "${FLAVOR}" = 'iojs' ]; then
    NODE_OR_IOJS="io.js"
  fi
  if [ "${NVM_NO_PROGRESS-}" = "1" ]; then
    # --silent, --show-error, use short option as @samrocketman mentions the compatibility issue.
    PROGRESS_BAR="-sS"
  else
    PROGRESS_BAR="--progress-bar"
  fi
  nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
  TARBALL="$(PROGRESS_BAR="${PROGRESS_BAR}" nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
  if [ -f "${TARBALL}" ]; then
    TMPDIR="$(dirname "${TARBALL}")/files"
  fi

  local UNTAR_SUCCESS
  UNTAR_SUCCESS=0

  # For Windows system (GitBash with MSYS, Cygwin)
  if [ "${NVM_OS}" = 'win' ]; then
    if (
      [ -n "${TMPDIR-}" ] && \
      command mkdir -p "${TMPDIR}" && \
      command unzip "${TARBALL}" -d "${TMPDIR}" && \
      VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")/bin" && \
      command mkdir -p "${VERSION_PATH}" && \
      command mv "${TMPDIR}/"*/* "${VERSION_PATH}" && \
      command rm -rf "${TMPDIR}"
    ); then
      UNTAR_SUCCESS=1
    fi
  # For non Windows system (including WSL running on Windows)
  else
    local tar_compression_flag
    tar_compression_flag='z'
    if nvm_supports_xz "${VERSION}"; then
      tar_compression_flag='J'
    fi

    local tar
    if [ "${NVM_OS}" = 'aix' ]; then
      tar='gtar'

Review comment (refactor):
```suggestion
  local EXTRACT_SUCCESS
  EXTRACT_SUCCESS=0
```
nit, ofc

Code after:
  local TARBALL
  local TMPDIR
  NVM_OS="${1}"
  PREFIXED_VERSION="${2}"
  VERSION="${3}"
  TARBALL="${4}"
  TMPDIR="${5}"

  local VERSION_PATH

  [ -n "${TMPDIR-}" ] && \
  command mkdir -p "${TMPDIR}" && \
  VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" || return 1

  # For Windows system (GitBash with MSYS, Cygwin)
  if [ "${NVM_OS}" = 'win' ]; then
    VERSION_PATH="${VERSION_PATH}/bin"
    command unzip -q "${TARBALL}" -d "${TMPDIR}" || return 1
  # For non Windows system (including WSL running on Windows)
  else
    local tar_compression_flag
    tar_compression_flag='z'
    if nvm_supports_xz "${VERSION}"; then
      tar_compression_flag='J'
    fi

    local tar
    if [ "${NVM_OS}" = 'aix' ]; then
      tar='gtar'
    else
      tar='tar'
    fi
    command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 || return 1
  fi

  command mkdir -p "${VERSION_PATH}" || return 1

  if [ "${NVM_OS}" = 'win' ]; then
    command mv "${TMPDIR}/"*/* "${VERSION_PATH}" || return 1
    command chmod +x "${VERSION_PATH}"/node.exe || return 1
    command chmod +x "${VERSION_PATH}"/npm || return 1
    command chmod +x "${VERSION_PATH}"/npx 2>/dev/null
  else
    command mv "${TMPDIR}/"* "${VERSION_PATH}" || return 1
  fi

  command rm -rf "${TMPDIR}"

  return 0
}
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
    ); then
      UNTAR_SUCCESS=1
    fi
  # For non Windows system (including WSL running on Windows)
  else
    local tar_compression_flag
    tar_compression_flag='z'
    if nvm_supports_xz "${VERSION}"; then
      tar_compression_flag='J'
    fi

    local tar
    if [ "${NVM_OS}" = 'aix' ]; then
      tar='gtar'
    else
      tar='tar'
    fi

    if (
      [ -n "${TMPDIR-}" ] && \
      command mkdir -p "${TMPDIR}" && \
      command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
      VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
      command mkdir -p "${VERSION_PATH}" && \
      command mv "${TMPDIR}/"* "${VERSION_PATH}" && \
      command rm -rf "${TMPDIR}"
    ); then
      UNTAR_SUCCESS=1
    fi
  fi

  if [ "$UNTAR_SUCCESS" -eq 1 ]; then
    if [ -n "${ALIAS-}" ]; then
      nvm alias "${ALIAS}" "${provided_version}"
    fi
    return 0
  fi

  nvm_err 'Binary download failed, trying source.'
  if [ -n "${TMPDIR-}" ]; then
    command rm -rf "${TMPDIR}"
  fi
  return 1
}

# args: flavor, kind, version
nvm_get_download_slug() {
  local FLAVOR
  case "${1-}" in
    node | iojs) FLAVOR="${1}" ;;
    *)

Review comment (refactor):
since this and the unzip command are the only difference between these two if blocks, can we restructure this so it's the same if, but with the extract command moved, perhaps, into a separate function that pivots based on the OS?

Code after:
  if [ "${NVM_OS}" = 'win' ]; then
    command mv "${TMPDIR}/"*/* "${VERSION_PATH}" || return 1
    command chmod +x "${VERSION_PATH}"/node.exe || return 1
    command chmod +x "${VERSION_PATH}"/npm || return 1
    command chmod +x "${VERSION_PATH}"/npx 2>/dev/null
  else
    command mv "${TMPDIR}/"* "${VERSION_PATH}" || return 1
  fi

  command rm -rf "${TMPDIR}"

  return 0
}

# args: flavor, type, version, reinstall
nvm_install_binary() {
  local FLAVOR
  case "${1-}" in
    node | iojs) FLAVOR="${1}" ;;
    *)
      nvm_err 'supported flavors: node, iojs'
      return 4
    ;;
  esac

  local TYPE
  TYPE="${2-}"

  local PREFIXED_VERSION
  PREFIXED_VERSION="${3-}"
  if [ -z "${PREFIXED_VERSION}" ]; then
    nvm_err 'A version number is required.'
    return 3
  fi

  local nosource
  nosource="${4-}"

  local VERSION
  VERSION="$(nvm_strip_iojs_prefix "${PREFIXED_VERSION}")"

  local NVM_OS
  NVM_OS="$(nvm_get_os)"

  if [ -z "${NVM_OS}" ]; then
    return 2
  fi

  local TARBALL
  local TMPDIR
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
  local NVM_ARCH
  NVM_ARCH="$(nvm_get_arch)"
  if ! nvm_is_merged_node_version "${VERSION}"; then
    if [ "${NVM_ARCH}" = 'armv6l' ] || [ "${NVM_ARCH}" = 'armv7l' ]; then
      NVM_ARCH="arm-pi"
    fi
  fi

  if [ "${KIND}" = 'binary' ]; then
    nvm_echo "${FLAVOR}-${VERSION}-${NVM_OS}-${NVM_ARCH}"
  elif [ "${KIND}" = 'source' ]; then
    nvm_echo "${FLAVOR}-${VERSION}"
  fi
}

# args: version
nvm_get_artifact_compression() {
  local VERSION
  VERSION="${1}"

  local NVM_OS
  NVM_OS="$(nvm_get_os)"

  local COMPRESSION
  COMPRESSION='tar.gz'
  if [ "_${NVM_OS}" = "_win" ]; then
    COMPRESSION='zip'
  elif nvm_supports_xz "${VERSION}"; then
    COMPRESSION='tar.xz'
  fi

  nvm_echo "${COMPRESSION}"
}

# args: flavor, kind, type, version
nvm_download_artifact() {
  local FLAVOR
  case "${1-}" in
    node | iojs) FLAVOR="${1}" ;;
    *)
      nvm_err 'supported flavors: node, iojs'
      return 1
    ;;
  esac

  local KIND
  case "${2-}" in
    binary | source) KIND="${2}" ;;
    *)
      nvm_err 'supported kinds: binary, source'
      return 1

Review comment (suggestion):
```suggestion
  if [ "_${NVM_OS}" = '_win' ]; then
```

Code after:
  if [ -n "${TMPDIR-}" ]; then
    command rm -rf "${TMPDIR}"
  fi
  return 1
}

# args: flavor, kind, version
nvm_get_download_slug() {
  local FLAVOR
  case "${1-}" in
    node | iojs) FLAVOR="${1}" ;;
    *)
      nvm_err 'supported flavors: node, iojs'
      return 1
    ;;
  esac

  local KIND
  case "${2-}" in
    binary | source) KIND="${2}" ;;
    *)
      nvm_err 'supported kinds: binary, source'
      return 2
    ;;
  esac

  local VERSION
  VERSION="${3-}"

  local NVM_OS
  NVM_OS="$(nvm_get_os)"

  local NVM_ARCH
  NVM_ARCH="$(nvm_get_arch)"
  if ! nvm_is_merged_node_version "${VERSION}"; then
    if [ "${NVM_ARCH}" = 'armv6l' ] || [ "${NVM_ARCH}" = 'armv7l' ]; then
      NVM_ARCH="arm-pi"
    fi
  fi

  if [ "${KIND}" = 'binary' ]; then
    nvm_echo "${FLAVOR}-${VERSION}-${NVM_OS}-${NVM_ARCH}"
  elif [ "${KIND}" = 'source' ]; then
    nvm_echo "${FLAVOR}-${VERSION}"
  fi
}

nvm_get_artifact_compression() {
  local VERSION
  VERSION="${1-}"
Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
    TMPDIR="$(dirname "${TARBALL}")/files"
  fi
  local tar
  tar='tar'
  if [ "${NVM_OS}" = 'aix' ]; then
    tar='gtar'
  fi
  if (
    [ -n "${TMPDIR-}" ] && \
    command mkdir -p "${TMPDIR}" && \
    command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
    VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
    command mkdir -p "${VERSION_PATH}" && \
    command mv "${TMPDIR}/"* "${VERSION_PATH}" && \
    command rm -rf "${TMPDIR}"
  ); then

    if [ -n "${ALIAS-}" ]; then
      nvm alias "${ALIAS}" "${provided_version}"
    fi
    return 0
  fi

  local nosource
  # Read nosource from arguments
  if [ $nosource -eq 1]; then
      nvm_err "Binary download failed"
      return 0

  nvm_err 'Binary download failed, trying source.'
  if [ -n "${TMPDIR-}" ]; then
    command rm -rf "${TMPDIR}"
  fi
  return 1
}

# args: flavor, kind, version
nvm_get_download_slug() {
  local FLAVOR
  case "${1-}" in
    node | iojs) FLAVOR="${1}" ;;
    *)
      nvm_err 'supported flavors: node, iojs'
      return 1
    ;;
  esac

  local KIND
  case "${2-}" in
    binary | source) KIND="${2}" ;;
    *)

Review comment (suggestion):
@ljharb What would be the best way to read the `-b` flag here. I could not see the `-s` flag being read anywhere. I just put a boolean here and thought that we could read the flag and set it accordingly

Code after:
      return 4
    ;;
  esac

  local TYPE
  TYPE="${2-}"

  local PREFIXED_VERSION
  PREFIXED_VERSION="${3-}"
  if [ -z "${PREFIXED_VERSION}" ]; then
    nvm_err 'A version number is required.'
    return 3
  fi

  local nosource
  nosource="${4-}"

  local VERSION
  VERSION="$(nvm_strip_iojs_prefix "${PREFIXED_VERSION}")"

  local NVM_OS
  NVM_OS="$(nvm_get_os)"

  if [ -z "${NVM_OS}" ]; then
    return 2
  fi

  local TARBALL
  local TMPDIR

  local PROGRESS_BAR
  local NODE_OR_IOJS
  if [ "${FLAVOR}" = 'node' ]; then
    NODE_OR_IOJS="${FLAVOR}"
  elif [ "${FLAVOR}" = 'iojs' ]; then
    NODE_OR_IOJS="io.js"
  fi
  if [ "${NVM_NO_PROGRESS-}" = "1" ]; then
    # --silent, --show-error, use short option as @samrocketman mentions the compatibility issue.
    PROGRESS_BAR="-sS"
  else
    PROGRESS_BAR="--progress-bar"
  fi
  nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
  TARBALL="$(PROGRESS_BAR="${PROGRESS_BAR}" nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
  if [ -f "${TARBALL}" ]; then
    TMPDIR="$(dirname "${TARBALL}")/files"
  fi

  if nvm_install_binary_extract "${NVM_OS}" "${PREFIXED_VERSION}" "${VERSION}" "${TARBALL}" "${TMPDIR}"; then
    if [ -n "${ALIAS-}" ]; then