From b688356c26406e32771a33206f37b9e3ce131a70 Mon Sep 17 00:00:00 2001 From: Thomas O'Donnell Date: Wed, 19 May 2021 20:47:38 +0200 Subject: [PATCH] refactor(install): Remove local from install.sh (#2745) Have removed the `local`s from `install.sh` to allow the script to work on ksh. --- install/install.sh | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/install/install.sh b/install/install.sh index 6e1c41ab1..9ae5722b0 100755 --- a/install/install.sh +++ b/install/install.sh @@ -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=" "