Skip to content

Commit 900d3d6

Browse files
alexhudspithrami3l
authored andcommitted
Add ksh compatibility for latest illumos and others
1 parent 2780881 commit 900d3d6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

rustup-init.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22
# shellcheck shell=dash
3+
# shellcheck disable=SC2039 # local is non-POSIX
34

45
# This is just a little script that can be downloaded from the internet to
56
# install rustup. It just does platform detection, downloads the installer
@@ -8,13 +9,15 @@
89
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
910
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
1011

11-
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
12-
# The version of ksh93 that ships with many illumos systems does not
13-
# support the "local" extension. Print a message rather than fail in
14-
# subtle ways later on:
15-
echo 'rustup does not work with this ksh93 version; please try bash!' >&2
16-
exit 1
17-
fi
12+
# Some versions of ksh have no `local` keyword. Alias it to `typeset`, but
13+
# beware this makes variables global with f()-style function syntax in ksh93.
14+
# mksh has this alias by default.
15+
has_local() {
16+
# shellcheck disable=SC2034 # deliberately unused
17+
local _has_local
18+
}
19+
20+
has_local 2>/dev/null || alias local=typeset
1821

1922

2023
set -u

0 commit comments

Comments
 (0)