Skip to content

Commit 6e495a5

Browse files
Rudi3kinnison
authored andcommitted
Move arch as local variable arguments to check_help_for
1 parent 710aa30 commit 6e495a5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

rustup-init.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ set -u
99
# If RUSTUP_UPDATE_ROOT is unset or empty, default it.
1010
RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}"
1111

12-
ARCH=
13-
1412
#XXX: If you change anything here, please make the same changes in setup_mode.rs
1513
usage() {
1614
cat 1>&2 <<EOF
@@ -48,17 +46,17 @@ main() {
4846
need_cmd rmdir
4947

5048
get_architecture || return 1
51-
ARCH="$RETVAL"
52-
assert_nz "$ARCH" "arch"
49+
local _arch="$RETVAL"
50+
assert_nz "$_arch" "arch"
5351

5452
local _ext=""
55-
case "$ARCH" in
53+
case "$_arch" in
5654
*windows*)
5755
_ext=".exe"
5856
;;
5957
esac
6058

61-
local _url="${RUSTUP_UPDATE_ROOT}/dist/${ARCH}/rustup-init${_ext}"
59+
local _url="${RUSTUP_UPDATE_ROOT}/dist/${_arch}/rustup-init${_ext}"
6260

6361
local _dir
6462
_dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t rustup)"
@@ -99,7 +97,7 @@ main() {
9997
fi
10098

10199
ensure mkdir -p "$_dir"
102-
ensure downloader "$_url" "$_file"
100+
ensure downloader "$_url" "$_file" "$_arch"
103101
ensure chmod u+x "$_file"
104102
if [ ! -x "$_file" ]; then
105103
printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
@@ -389,14 +387,14 @@ downloader() {
389387
if [ "$1" = --check ]; then
390388
need_cmd "$_dld"
391389
elif [ "$_dld" = curl ]; then
392-
if ! check_help_for curl --proto --tlsv1.2; then
390+
if ! check_help_for "$3" curl --proto --tlsv1.2; then
393391
echo "Warning: Not forcing TLS v1.2, this is potentially less secure"
394392
curl --silent --show-error --fail --location "$1" --output "$2"
395393
else
396394
curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2"
397395
fi
398396
elif [ "$_dld" = wget ]; then
399-
if ! check_help_for wget --https-only --secure-protocol; then
397+
if ! check_help_for "$3" wget --https-only --secure-protocol; then
400398
echo "Warning: Not forcing TLS v1.2, this is potentially less secure"
401399
wget "$1" -O "$2"
402400
else
@@ -408,14 +406,17 @@ downloader() {
408406
}
409407

410408
check_help_for() {
409+
local _arch
411410
local _cmd
412411
local _arg
413412
local _ok
413+
_arch="$1"
414+
shift
414415
_cmd="$1"
415416
_ok="y"
416417
shift
417418

418-
case "$ARCH" in
419+
case "$_arch" in
419420

420421
# If we're running on OS-X, older than 10.13, then we always
421422
# fail to find these options to force fallback

0 commit comments

Comments
 (0)