Skip to content

Commit f91be56

Browse files
committed
Move arch as local variable arguments to check_help_for
1 parent aa903d4 commit f91be56

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
@@ -381,14 +379,14 @@ downloader() {
381379
if [ "$1" = --check ]; then
382380
need_cmd "$_dld"
383381
elif [ "$_dld" = curl ]; then
384-
if ! check_help_for curl --proto --tlsv1.2; then
382+
if ! check_help_for "$3" curl --proto --tlsv1.2; then
385383
echo "Warning: Not forcing TLS v1.2, this is potentially less secure"
386384
curl --silent --show-error --fail --location "$1" --output "$2"
387385
else
388386
curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2"
389387
fi
390388
elif [ "$_dld" = wget ]; then
391-
if ! check_help_for wget --https-only --secure-protocol; then
389+
if ! check_help_for "$3" wget --https-only --secure-protocol; then
392390
echo "Warning: Not forcing TLS v1.2, this is potentially less secure"
393391
wget "$1" -O "$2"
394392
else
@@ -400,14 +398,17 @@ downloader() {
400398
}
401399

402400
check_help_for() {
401+
local _arch
403402
local _cmd
404403
local _arg
405404
local _ok
405+
_arch="$1"
406+
shift
406407
_cmd="$1"
407408
_ok="y"
408409
shift
409410

410-
case "$ARCH" in
411+
case "$_arch" in
411412

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

0 commit comments

Comments
 (0)