refactor(install): Remove local from install.sh (#2745)

Have removed the `local`s from `install.sh` to allow the script to work
on ksh.
This commit is contained in:
Thomas O'Donnell 2021-05-19 20:47:38 +02:00 committed by GitHub
parent 78b84c9f34
commit b688356c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 23 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env sh
# shellcheck disable=SC2039
set -eu
printf '\n'
@ -44,7 +42,6 @@ has() {
# Gets path to a temporary file, even if
get_tmpfile() {
local suffix
suffix="$1"
if has mktemp; then
printf "%s.%s" "$(mktemp)" "${suffix}"
@ -57,7 +54,6 @@ get_tmpfile() {
# Test if a location is writeable by trying to write to it. Windows does not let
# you test writeability other than by writing: https://stackoverflow.com/q/1999988
test_writeable() {
local path
path="${1:-}/test.txt"
if touch "${path}" 2>/dev/null; then
rm "${path}"
@ -94,9 +90,9 @@ download() {
}
unpack() {
local archive=$1
local bin_dir=$2
local sudo=${3-}
archive=$1
bin_dir=$2
sudo=${3-}
case "$archive" in
*.tar.gz)
@ -166,10 +162,7 @@ elevate_priv() {
}
install() {
local msg
local sudo
local archive
local ext="$1"
ext="$1"
if test_writeable "${BIN_DIR}"; then
sudo=""
@ -198,7 +191,6 @@ install() {
# - linux_musl (Alpine)
# - freebsd
detect_platform() {
local platform
platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
case "${platform}" in
@ -221,7 +213,6 @@ detect_platform() {
# - arm
# - arm64
detect_arch() {
local arch
arch="$(uname -m | tr '[:upper:]' '[:lower:]')"
case "${arch}" in
@ -241,9 +232,9 @@ detect_arch() {
}
detect_target() {
local arch="$1"
local platform="$2"
local target="$arch-$platform"
arch="$1"
platform="$2"
target="$arch-$platform"
if [ "${target}" = "arm-unknown-linux-musl" ]; then
target="${target}eabihf"
@ -272,7 +263,7 @@ confirm() {
}
check_bin_dir() {
local bin_dir="$1"
bin_dir="$1"
if [ ! -d "$BIN_DIR" ]; then
error "Installation location $BIN_DIR does not appear to be a directory"
@ -282,7 +273,6 @@ check_bin_dir() {
fi
# https://stackoverflow.com/a/11655875
local good
good=$(
IFS=:
for path in $PATH; do
@ -299,11 +289,9 @@ check_bin_dir() {
}
is_build_available() {
local arch="$1"
local platform="$2"
local target="$3"
local good
arch="$1"
platform="$2"
target="$3"
good=$(
IFS=" "