Skip to content
Myr

[Robustness] avoid a `set -u` error when `$_` is unset

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Sourcing nvm.sh under `set -u` on a POSIX shell that leaves `$_` unset (e.g. busybox ash or dash on Alpine, where the parent shell does not export it) aborted at `NVM_SCRIPT_SOURCE="$_"`. Default to empty; the only consumer already falls back to `$0`.

authored by Jordan Harband · committed by Jordan Harband · parent 86c9374 · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:nvm.sh+1 added-1 removed
9 unmodified lines
10# shellcheck disable=SC2039,SC2016,SC2001,SC304311{ # this ensures the entire script is downloaded #1213# shellcheck disable=SC302814NVM_SCRIPT_SOURCE="$_"14NVM_SCRIPT_SOURCE="${_:-}"1516nvm_is_zsh() {17 [ -n "${ZSH_VERSION-}" ]18}
4934 unmodified lines