Skip to content

Commit

Permalink
Add ksh compatibility for latest illumos and others
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhudspith authored and rami3l committed Oct 10, 2023
1 parent 2780881 commit 900d3d6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions rustup-init.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 900d3d6

Please sign in to comment.