From 0992b4385f9f41212f84a24d693266e50da24b79 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:52:58 -0300 Subject: [PATCH 01/12] temporarially enable tracing --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index aab910e3..b4cbb403 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,7 +9,7 @@ ###################################################### set -o errexit -# set -o xtrace +set -o xtrace ################################################ # CONSTANTS ################################################ From 32ea373aec36b466b352b88e1ba7b83ca7a8ef16 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:53:52 -0300 Subject: [PATCH 02/12] use clear variable --- installer/install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index b4cbb403..4630332d 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -39,8 +39,7 @@ GRAY='\e[0;90m' CLEAR='\e[0m' printColorized() { - NC='\e[0m' - printf "${1}${2}${NC}" + printf "${1}${2}${CLEAR}" } panic() { From 6298625c86e7f855c51c60995a3e9c46b3a4454d Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:02:12 -0300 Subject: [PATCH 03/12] double-quote to avoid re-splitting --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 4630332d..df87db87 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -17,7 +17,7 @@ set -o xtrace REPO="arturo" VERSION="full" -for cmd in $@; do +for cmd in "$@"; do case $cmd in --nightly|-n) REPO="nightly";; --mini|-m) VERSION="mini";; From 08d8d507dc83d339dd96bb76e126ff0bd5da283c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:04:37 -0300 Subject: [PATCH 04/12] remove &> shorthand In POSIX this is undefined --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index df87db87..2c7b6b20 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -125,7 +125,7 @@ cleanup_tmp_directory() { } command_exists(){ - type "$1" &> /dev/null + type "$1" > /dev/null 2>&1 } animate_progress(){ From 4d0ed0eb2a4c238d5a3ed1ae07aa7d3f4007446d Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:07:36 -0300 Subject: [PATCH 05/12] use new syntax the legacy one is harder to debug, see: https://www.shellcheck.net/wiki/SC2006 --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 2c7b6b20..5b3af27a 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -162,7 +162,7 @@ verifyOS(){ elif [ `uname` = "FreeBSD" ]; then currentOS="freebsd" else - currentOS="Unknown ($OSTYPE / `uname`)" + currentOS="Unknown ($OSTYPE / $(uname))" fi ;; esac From caf48cc464058927a7ec817547d87ae53241ec2a Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:08:11 -0300 Subject: [PATCH 06/12] use new syntax the legacy one is harder to debug, see: https://www.shellcheck.net/wiki/SC2006 --- installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 5b3af27a..6cccce89 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -157,9 +157,9 @@ verifyOS(){ freebsd*) currentOS="freebsd" ;; bsd*) currentOS="bsd" ;; *) - if [ `uname` = "Linux" ]; then + if [ "$(uname)" = "Linux" ]; then currentOS="linux" - elif [ `uname` = "FreeBSD" ]; then + elif [ "$(uname)" = "FreeBSD" ]; then currentOS="freebsd" else currentOS="Unknown ($OSTYPE / $(uname))" From 4dc17775170934c9843034fd0f7f9d0702acf992 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:09:59 -0300 Subject: [PATCH 07/12] disable shellcheck for "~" --- installer/install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index 6cccce89..4604345c 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -173,15 +173,19 @@ verifyShell(){ case "$SHELL" in */bin/zsh) currentShell="zsh" ; + # shellcheck disable=SC2088 shellRcFile="~/.zshrc" ;; */bin/bash) currentShell="bash" ; + # shellcheck disable=SC2088 shellRcFile="~/.bashrc or ~/.profile" ;; */bin/sh) currentShell="sh" ; + # shellcheck disable=SC2088 shellRcFile="~/.profile" ;; *) currentShell="unrecognized" ; + # shellcheck disable=SC2088 shellRcFile="~/.profile" ;; esac From bc57fb0eec1d2f393c7e5b703b774b150e1f125d Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:13:44 -0300 Subject: [PATCH 08/12] deprecate windows support --- installer/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 4604345c..3de9d9f6 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -262,7 +262,7 @@ main() { verifyOS verifyShell - if [ "$currentOS" = "linux" ] || [ "$currentOS" = "macos" ] || [ "$currentOS" = "windows-msys2" ]; then + if [ "$currentOS" = "linux" ] || [ "$currentOS" = "macos" ]; then section "Checking prerequisites..." install_prerequisites @@ -280,6 +280,8 @@ main() { section "Done!" eecho "" showFooter + elif [ "$currentOS" = "windows-msys2" ]; then + panic "Cannot continue. Try to install via install.ps1"; else panic "Cannot continue. Unfortunately your OS is not supported by this auto-installer."; fi From d67dcb8a7c1daad6d6c73cc46f9c5601577ecd88 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:14:09 -0300 Subject: [PATCH 09/12] windows-msys2 should not exist --- installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 3de9d9f6..24c5f936 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -151,8 +151,8 @@ verifyOS(){ case "$OSTYPE" in linux*) currentOS="linux" ;; darwin*) currentOS="macos" ;; - cygwin*) currentOS="windows-msys2" ;; - msys*) currentOS="windows-msys2" ;; + cygwin*) currentOS="windows" ;; + msys*) currentOS="windows" ;; solaris*) currentOS="solaris" ;; freebsd*) currentOS="freebsd" ;; bsd*) currentOS="bsd" ;; From d93fc11a7cfc427ee936d137df7017c8e96d4090 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:17:06 -0300 Subject: [PATCH 10/12] split into multiplefunctinos --- installer/install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index 24c5f936..24f72983 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -226,7 +226,9 @@ download_arturo() { --output "$ARTURO_TMP_DIR/arturo.tar.gz" \ --silent \ --show-error +} +unpack_arturo() { # This piece of code is using traditional option style due # to compatibility issues between `tar`'s versions. # Long versions are accepted for `GNU's tar`, and for others ones @@ -270,6 +272,7 @@ main() { download_arturo section "Installing..." + unpack_arturo install_arturo section "Cleaning up..." From 93186335ea1bc741b5821b5153e49a8b4967441c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:17:21 -0300 Subject: [PATCH 11/12] fix elif branch --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 24f72983..fce56fd1 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -283,7 +283,7 @@ main() { section "Done!" eecho "" showFooter - elif [ "$currentOS" = "windows-msys2" ]; then + elif [ "$currentOS" = "windows" ]; then panic "Cannot continue. Try to install via install.ps1"; else panic "Cannot continue. Unfortunately your OS is not supported by this auto-installer."; From ebf3c27a7de84d13244130d0f2d703f10bac2a2a Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:13:30 -0300 Subject: [PATCH 12/12] linux should unpack `tar` and mac `zip` --- installer/install.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index fce56fd1..e943b7d6 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -30,8 +30,10 @@ API_URL="https://api.github.com/repos/arturo-lang/${REPO}/releases" # HELPERS ################################################ +# shellcheck disable=SC2034 RED='\e[0;31m' GREEN='\e[1;32m' +# shellcheck disable=SC2034 BLUE='\e[0;34m' MAGENTA='\e[1;35m' CYAN='\e[1;36m' @@ -228,7 +230,7 @@ download_arturo() { --show-error } -unpack_arturo() { +unpack_tar() { # This piece of code is using traditional option style due # to compatibility issues between `tar`'s versions. # Long versions are accepted for `GNU's tar`, and for others ones @@ -242,6 +244,13 @@ unpack_arturo() { tar -zxf "$ARTURO_TMP_DIR/arturo.tar.gz" -C $ARTURO_TMP_DIR } +unpack_zip() { + # It seems that `unzip` doesn't provide a long version of its options. + # + # -d: directory to which to extract files. + unzip "$ARTURO_TMP_DIR/arturo.zip" -d "$ARTURO_TMP_DIR" +} + install_arturo() { create_directory $HOME/.arturo/bin create_directory $HOME/.arturo/lib @@ -272,7 +281,12 @@ main() { download_arturo section "Installing..." - unpack_arturo + if [ "$currentOS" = "linux" ]; then + unpack_tar + else + unpack_zip + fi + install_arturo section "Cleaning up..."