From 9ac58a13ef89ae94a140f577a914b7b978b326ac Mon Sep 17 00:00:00 2001 From: frosty Date: Sun, 21 Jul 2024 20:15:41 -0400 Subject: [PATCH] fix shellcheck warnings and rename variables to be consistent --- start.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/start.sh b/start.sh index 2dd32630..2590d9d3 100755 --- a/start.sh +++ b/start.sh @@ -1,31 +1,34 @@ #!/bin/sh -RC='\033[0m' -RED='\033[0;31m' +rc='\033[0m' +red='\033[0;31m' -linutil="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" +binary_url="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil" check() { - local exit_code=$1 - local message=$2 + exit_code=$1 + message=$2 - if [ $exit_code -ne 0 ]; then - echo -e "${RED}ERROR: $message${RC}" + if [ "$exit_code" -ne 0 ]; then + printf '%sERROR: %s%s\n' "$red" "$message" "$rc" exit 1 fi + + unset exit_code + unset message } -TMPFILE=$(mktemp) +temp_file=$(mktemp) check $? "Creating the temporary file" -curl -fsL $linutil -o $TMPFILE +curl -fsL "$binary_url" -o "$temp_file" check $? "Downloading linutil" -chmod +x $TMPFILE +chmod +x "$temp_file" check $? "Making linutil executable" -"$TMPFILE" +"$temp_file" check $? "Executing linutil" -rm -f $TMPFILE +rm -f "$temp_file" check $? "Deleting the temporary file"