From 2c8e5ea129dc4c8900f15fc4ccc103e0d48e0295 Mon Sep 17 00:00:00 2001 From: Alex Hudspith Date: Fri, 8 Sep 2023 14:28:42 +0100 Subject: [PATCH 1/2] Add ksh compatibility for latest illumos and others --- rustup-init.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rustup-init.sh b/rustup-init.sh index a7701c5336..796f2310fa 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -1,5 +1,6 @@ #!/bin/sh # shellcheck shell=dash +# shellcheck disable=SC2039 # local is non-POSIX # This is just a little script that can be downloaded from the internet to # install rustup. It just does platform detection, downloads the installer @@ -8,13 +9,15 @@ # It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local` # extension. Note: Most shells limit `local` to 1 var per line, contra bash. -if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then - # The version of ksh93 that ships with many illumos systems does not - # support the "local" extension. Print a message rather than fail in - # subtle ways later on: - echo 'rustup does not work with this ksh93 version; please try bash!' >&2 - exit 1 -fi +# Some versions of ksh have no `local` keyword. Alias it to `typeset`, but +# beware this makes variables global with f()-style function syntax in ksh93. +# mksh has this alias by default. +has_local() { + # shellcheck disable=SC2034 # deliberately unused + local _has_local +} + +has_local 2>/dev/null || alias local=typeset set -u From fe8c168636c9ca219fc57830e3987581ac9ed897 Mon Sep 17 00:00:00 2001 From: Alex Hudspith Date: Fri, 8 Sep 2023 14:29:29 +0100 Subject: [PATCH 2/2] Fix zsh word splitting for curl "--retry 3" --- rustup-init.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rustup-init.sh b/rustup-init.sh index 796f2310fa..c274345f33 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -19,6 +19,10 @@ has_local() { has_local 2>/dev/null || alias local=typeset +# zsh does not split words by default, Required for curl retry arguments below. +if [ -n "$ZSH_VERSION" ]; then + setopt shwordsplit +fi set -u