Skip to content
Myr

[Fix] avoid OpenBSD `nvm install` error when /sbin/init doesn't exist

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

`nvm install` fails with "Binary download failed, trying source" when - running on Bash; - errtrace (`set -E`) is enabled; - an ERR trap uses `exit` to return a non-zero status; and - /sbin/init doesn't exist. Resolved by moving `ls -dl /sbin/init` to the following `if` statement. In this context, returning non-zero isn't an error and the ERR trap isn't executed.

authored by Luke Arms · committed by Jordan Harband · parent 81f0f3e · Browse files · 1 file+5 added−3 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+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:nvm.sh+5 added-3 removed
1868 unmodified lines
1869 aarch64) NVM_ARCH="arm64" ;;1870 *) NVM_ARCH="${HOST_ARCH}" ;;1871 esac18721873 # If running a 64bit ARM kernel but a 32bit ARM userland, change ARCH to 32bit ARM (armv7l)1873 # If running a 64bit ARM kernel but a 32bit ARM userland,1874 # change ARCH to 32bit ARM (armv7l) if /sbin/init is 32bit executable1875 local L1875 L=$(ls -dl /sbin/init 2>/dev/null) # if /sbin/init is 32bit executable1876 if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] && [ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then1876 if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] &&1877 L="$(ls -dl /sbin/init 2>/dev/null)" &&1878 [ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then1879 NVM_ARCH=armv7l1880 HOST_ARCH=armv7l1881 fi1882
2471 unmodified lines