mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-10-11 00:00:13 +08:00
`nvm_install_binary` and `nvm_install_source` declared `local TMPDIR` without initializing it, and remove it with `rm -rf` on failure. dash's `local` keeps the caller's value, as does bash's when `TMPDIR` is passed as a prefix assignment (`TMPDIR=… nvm install`), so a failed download removed the caller's temp directory; on macOS, `tar` instead blocked reading the archive from the terminal.
31 lines
799 B
Bash
Executable File
31 lines
799 B
Bash
Executable File
#!/bin/sh
|
|
|
|
WORK="${PWD}/nvm-inherited-tmpdir-work.$$"
|
|
|
|
cleanup() {
|
|
command rm -rf "${WORK}"
|
|
unset -f cleanup die nvm_download_artifact
|
|
}
|
|
die () { echo "$@" ; cleanup ; exit 1; }
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
nvm_download_artifact() { return 1; }
|
|
|
|
make_canary() {
|
|
command rm -rf "${WORK}/tmp"
|
|
command mkdir -p "${WORK}/tmp"
|
|
echo canary > "${WORK}/tmp/canary"
|
|
}
|
|
|
|
make_canary
|
|
TMPDIR="${WORK}/tmp" nvm_install_binary node std 8.0.0 0 < /dev/null > /dev/null 2>&1
|
|
[ -f "${WORK}/tmp/canary" ] || die 'nvm_install_binary removed the TMPDIR it inherited after a failed download'
|
|
|
|
make_canary
|
|
TMPDIR="${WORK}/tmp" nvm_install_source node std 8.0.0 < /dev/null > /dev/null 2>&1
|
|
[ -f "${WORK}/tmp/canary" ] || die 'nvm_install_source removed the TMPDIR it inherited after a failed download'
|
|
|
|
cleanup
|