From 710aa306e38c1ba04b16ae1a771e19b512500521 Mon Sep 17 00:00:00 2001 From: Rudolf Blahout Date: Mon, 7 Oct 2019 15:51:13 +0200 Subject: [PATCH 1/2] Add OS detection in check_help_for --- rustup-init.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/rustup-init.sh b/rustup-init.sh index cd58f3760a..145665aecf 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -9,6 +9,8 @@ set -u # If RUSTUP_UPDATE_ROOT is unset or empty, default it. RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}" +ARCH= + #XXX: If you change anything here, please make the same changes in setup_mode.rs usage() { cat 1>&2 < Date: Wed, 4 Dec 2019 16:54:19 +0100 Subject: [PATCH 2/2] Move arch as local variable arguments to check_help_for --- rustup-init.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rustup-init.sh b/rustup-init.sh index 145665aecf..0020276a10 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -9,8 +9,6 @@ set -u # If RUSTUP_UPDATE_ROOT is unset or empty, default it. RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}" -ARCH= - #XXX: If you change anything here, please make the same changes in setup_mode.rs usage() { cat 1>&2 <&2 @@ -389,14 +387,14 @@ downloader() { if [ "$1" = --check ]; then need_cmd "$_dld" elif [ "$_dld" = curl ]; then - if ! check_help_for curl --proto --tlsv1.2; then + if ! check_help_for "$3" curl --proto --tlsv1.2; then echo "Warning: Not forcing TLS v1.2, this is potentially less secure" curl --silent --show-error --fail --location "$1" --output "$2" else curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" fi elif [ "$_dld" = wget ]; then - if ! check_help_for wget --https-only --secure-protocol; then + if ! check_help_for "$3" wget --https-only --secure-protocol; then echo "Warning: Not forcing TLS v1.2, this is potentially less secure" wget "$1" -O "$2" else @@ -408,14 +406,17 @@ downloader() { } check_help_for() { + local _arch local _cmd local _arg local _ok + _arch="$1" + shift _cmd="$1" _ok="y" shift - case "$ARCH" in + case "$_arch" in # If we're running on OS-X, older than 10.13, then we always # fail to find these options to force fallback