From 07e754b3f29d9810f48d69e2b3c4770c82f5f8a5 Mon Sep 17 00:00:00 2001 From: Nyx <144965845+nnyyxxxx@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:48:01 -0400 Subject: [PATCH] Fix local vars bashisms that are not defined in posix (#548) Co-authored-by: nnyyxxxx --- startdev.sh | 25 ++++++++++++------------- tabs/utils/ollama.sh | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/startdev.sh b/startdev.sh index 5fb2f1b2b..5aad12ad8 100755 --- a/startdev.sh +++ b/startdev.sh @@ -11,32 +11,31 @@ get_latest_release() { grep -oP '"tag_name": "\K[^"]*' | head -n 1) if [ -z "$latest_release" ]; then - echo "Error fetching release data" >&2 + printf "%b\n" "Error fetching release data" >&2 return 1 fi - echo "$latest_release" + printf "%b\n" "$latest_release" } # Function to redirect to the latest pre-release version redirect_to_latest_pre_release() { - local latest_release latest_release=$(get_latest_release) if [ -n "$latest_release" ]; then url="https://github.com/ChrisTitusTech/linutil/releases/download/$latest_release/linutil" else - echo 'Unable to determine latest pre-release version.' >&2 - echo "Using latest Full Release" + printf "%b\n" 'Unable to determine latest pre-release version.' >&2 + printf "%b\n" "Using latest Full Release" url="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" fi addArch - echo "Using URL: $url" # Log the URL being used + printf "%b\n" "Using URL: $url" } check() { - local exit_code=$1 - local message=$2 + exit_code=$1 + message=$2 - if [ $exit_code -ne 0 ]; then + if [ "$exit_code" -ne 0 ]; then printf "%b\n" "${RED}ERROR: $message${RC}" exit 1 fi @@ -63,16 +62,16 @@ redirect_to_latest_pre_release TMPFILE=$(mktemp) check $? "Creating the temporary file" -echo "Downloading linutil from $url" # Log the download attempt -curl -fsL $url -o $TMPFILE +printf "%b\n" "Downloading linutil from $url" +curl -fsL "$url" -o "$TMPFILE" check $? "Downloading linutil" -chmod +x $TMPFILE +chmod +x "$TMPFILE" check $? "Making linutil executable" "$TMPFILE" check $? "Executing linutil" -rm -f $TMPFILE +rm -f "$TMPFILE" check $? "Deleting the temporary file" } # End of wrapping diff --git a/tabs/utils/ollama.sh b/tabs/utils/ollama.sh index f93cc7416..64f825bfa 100644 --- a/tabs/utils/ollama.sh +++ b/tabs/utils/ollama.sh @@ -54,7 +54,7 @@ display_models() { # Function to select model based on user input select_model() { - local choice="$1" + choice="$1" case $choice in 1) printf "%b\n" "llama3.1";; 2) printf "%b\n" "llama3.1:70b";;