- Fix typo in ERROR variable
- Added function for error printing and exiting
This commit is contained in:
Katy248 2024-10-28 15:48:57 +03:00
parent 082221133b
commit eb39c2129e

View File

@ -23,7 +23,7 @@ RESET="\e[0m" # Reset colors
LOG="${BLUE}[LOG]${RESET}" LOG="${BLUE}[LOG]${RESET}"
WARNING="${YELLOW}[WARNING]${RESET}" WARNING="${YELLOW}[WARNING]${RESET}"
ERORR="${RED}[ERROR]${RESET}" ERROR="${RED}[ERROR]${RESET}"
SUCCES="${GREEN}[SUCCES]${RESET}" SUCCES="${GREEN}[SUCCES]${RESET}"
CHECK="${GREEN}[CHECK]${RESET}" CHECK="${GREEN}[CHECK]${RESET}"
@ -116,6 +116,14 @@ case "${OS_ID}" in
;; ;;
esac esac
# Prints error message and exits with code 1
# $1 - message
print_err() {
local msg=$1
echo -e "${ERROR} ${msg}" >&2
exit 1
}
install_deps() { install_deps() {
_bold=$(tput bold) _bold=$(tput bold)
@ -128,19 +136,17 @@ install_deps() {
exit 1 exit 1
fi fi
if ! sudo pacman -S "${DEPENDENCIES[@]}"; then if ! sudo pacman -S "${DEPENDENCIES[@]}"; then
echo -e "$ERROR Pacman terminated with an error." print_err "Pacman terminated with an error."
exit 1
fi fi
;; ;;
"redos") "redos")
echo -e "${LOG} RED OS install"
if ! pkexec dnf install "${DEPENDENCIES[@]}" -y --comment "Installed via 'photoshop-linux' script" ;then if ! pkexec dnf install "${DEPENDENCIES[@]}" -y --comment "Installed via 'photoshop-linux' script" ;then
echo -e "${ERROR} ${_bold}DNF${RESET} terminated with an error." >&2 print_err "${_bold}DNF${RESET} terminated with an error."
exit 1
fi fi
;; ;;
*) *)
echo -e "$ERROR For now only ${BLUE}Arch Linux${RESET} is supported." print_err "For now only ${BLUE}Arch Linux${RESET} is supported."
exit 1
;; ;;
esac esac
echo -e "$LOG Missing dependencies was installed" echo -e "$LOG Missing dependencies was installed"