Skip to content

Commit

Permalink
Fix formatting constants being declared after first usage
Browse files Browse the repository at this point in the history
This change doesn't affect functionality.
The only thing changed is the "failed to source pi-apps api script" error is now properly formatted.
  • Loading branch information
Itai-Nelken authored Nov 10, 2024
1 parent 55261d6 commit d3cb2bf
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pi-apps-terminal-bash-edition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@
### ignore some shellcheck warnings
# shellcheck disable=SC2145,SC2199,SC2068,SC2013,SC1090,SC2034

#text formatting variables
readonly red="\e[31m"
readonly green="\e[32m"
readonly yellow="\e[33m"
readonly blue="\e[34m"
readonly light_red="\e[91m"
readonly light_green="\e[92m"
readonly light_yellow="\e[93m"
readonly light_blue="\e[94m"
readonly cyan="\e[36m"
readonly white="\e[97m"
readonly dark_grey_background="\e[100m"
readonly bold="\e[1m"
readonly underline="\e[4m"
readonly inverted="\e[7m"
readonly normal="\e[0m"

#directory variables
if [[ -z "$DIRECTORY" ]]; then
DIRECTORY="$HOME/pi-apps"
fi

#check if "$DIRECTORY/api" exists
if [[ ! -f "$DIRECTORY/api" ]]; then
echo -e "\e[1;31m[!] \e[0;31mThe pi-apps \"api\" script doesn't exist!\e[0m"
echo -e "${bold}${red}[!] \e[0;31mThe pi-apps \"api\" script doesn't exist!${normal}"
echo -e "Please report this here: https://github.com/Itai-Nelken/PiApps-terminal_bash-edition/issues/new"
exit 1
fi
Expand All @@ -23,23 +40,6 @@ fi
#unset the error function from the api script, we wan't to use our own defined later
unset error

#text formatting variables
readonly red="\e[31m"
readonly green="\e[32m"
readonly yellow="\e[33m"
readonly blue="\e[34m"
readonly light_red="\e[91m"
readonly light_green="\e[92m"
readonly light_yellow="\e[93m"
readonly light_blue="\e[94m"
readonly cyan="\e[36m"
readonly white="\e[97m"
readonly dark_grey_background="\e[100m"
readonly bold="\e[1m"
readonly underline="\e[4m"
readonly inverted="\e[7m"
readonly normal="\e[0m"

function error() {
echo -e "${red}${bold}[!]${normal} ${light_red}$1${normal}" 1>&2
exit 1
Expand Down

0 comments on commit d3cb2bf

Please sign in to comment.