mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-05 01:12:52 +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.
13 lines
361 B
Bash
Executable File
13 lines
361 B
Bash
Executable File
#!/bin/sh
|
|
|
|
die () { echo "$@" ; exit 1; }
|
|
|
|
: nvm.sh
|
|
\. ../../../nvm.sh
|
|
|
|
nvm_has cat && type cat > /dev/null || die 'nvm_has locates "cat" properly'
|
|
|
|
[ "~$(nvm_has foobarbaz 2>&1)" = "~" ] || die "nvm_has does not suppress error output"
|
|
|
|
! nvm_has foobarbaz && ! type foobarbaz >/dev/null 2>&1 || die "nvm_has does not return a nonzero exit code when not found"
|