mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 08:52:48 +08:00
nvm.sh uses `NVM_SCRIPT_SOURCE="$_"` to detect its source location. Adding `: nvm.sh` before each source line ensures `$_` is set correctly, preventing breakage when the previous command (e.g., `set -ex`) overwrites it.
21 lines
413 B
Bash
Executable File
21 lines
413 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -ex
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
export NVM_DIR_BASE="/tmp"
|
|
export NVM_DIR="${NVM_DIR_BASE}/"
|
|
|
|
: nvm.sh
|
|
\. ../../nvm.sh
|
|
|
|
[ "${NVM_DIR}" = "${NVM_DIR_BASE}" ] || die 'nvm should remove the last trailing slash in "$NVM_DIR"'
|
|
|
|
export NVM_DIR="${NVM_DIR_BASE}//"
|
|
|
|
: nvm.sh
|
|
\. ../../nvm.sh
|
|
|
|
[ "${NVM_DIR}" = "${NVM_DIR_BASE}" ] || die 'nvm should remove all the last trailing slashes in "$NVM_DIR"'
|