Skip to content

Commit edacf82

Browse files
signed-logljharb
authored andcommitted
[Fix] Remove unneeded call to ls in nvm_arch
Remove the call to `ls` that was used to determine the symlink destination Reasoning : * `od` resolves symlink itself due to the use of `fopen` * Prevent the behaviour of `od` which will hang if the filename is empty (i.e. `/sbin/init` missing) as it will be waiting for `stdin` compared to quitting with error if the file just doesn't exist Fixes #3006
1 parent f36516b commit edacf82

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nvm.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,10 +1917,10 @@ nvm_get_arch() {
19171917

19181918
# If running a 64bit ARM kernel but a 32bit ARM userland,
19191919
# change ARCH to 32bit ARM (armv7l) if /sbin/init is 32bit executable
1920-
local L
1921-
if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] &&
1922-
L="$(command ls -dl /sbin/init 2>/dev/null)" &&
1923-
[ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then
1920+
if [ "$(uname)" = "Linux" ] \
1921+
&& [ "${NVM_ARCH}" = arm64 ] \
1922+
&& [ "$(command od -An -t x1 -j 4 -N 1 "/sbin/init" 2>/dev/null)" = ' 01' ]\
1923+
; then
19241924
NVM_ARCH=armv7l
19251925
HOST_ARCH=armv7l
19261926
fi

0 commit comments

Comments
 (0)