Skip to content

Commit 2b9619c

Browse files
committed
Avoid sysctl: unknown oid stderr output and/or non-zero exit code
1 parent 4dfe254 commit 2b9619c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rustup-init.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ get_architecture() {
261261
# get the real answer, but that's hard to ensure, so instead we use
262262
# `sysctl` (which doesn't lie) to check for the actual architecture.
263263
if [ "$_cputype" = i386 ]; then
264-
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
264+
# Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
265+
if sysctl hw.optional.x86_64 2> /dev/null || true | grep -q ': 1'; then
265266
_cputype=x86_64
266267
fi
267268
elif [ "$_cputype" = x86_64 ]; then
268-
if sysctl hw.optional.arm64 | grep -q ': 1'; then
269+
# Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
270+
if sysctl hw.optional.arm64 2> /dev/null || true | grep -q ': 1'; then
269271
_cputype=arm64
270272
fi
271273
fi

0 commit comments

Comments
 (0)