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

Code before:
  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
  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

Review comment (suggestion):
In order to get this to actually work on Cygwin, I had to add this line right after the unzip:

```sh
command chmod -f +x "${VERSION_PATH}"/{node.exe,npm,npx}
```

The node zipfiles do not have the executable bit set on their contents, so installing without the chmod causes the installation not to be usable (or even recognized by nvm itself as a valid install).  I imagine it would apply to MSYS as well, but I haven't tested.  (The `-f` handles the case where npx is not included on older node versions.)

Code after:
  if [ "$#" -ne 5 ]; then
    nvm_err 'nvm_install_binary_extract needs 5 parameters'
    return 1
  fi

  local NVM_OS
  local PREFIXED_VERSION
  local VERSION
  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