v3-revamp
This commit is contained in:
+12
-32
@@ -1,51 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# If debug is enabled, we remove '-e' dynamically inside the initialization so it doesn't instantly crash during debugging steps
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
# Color helpers (printf-safe, no tput)
|
# Color helpers (printf-safe, no tput)
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
RED='\033[0;31m'
|
# ... (Keep your color definitions here) ...
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[0;33m'
|
|
||||||
CYAN='\033[0;36m'
|
|
||||||
PURPLE='\033[0;35m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
GRAY='\033[0;37m'
|
|
||||||
BOLD='\033[1m'
|
|
||||||
RESET='\033[0m'
|
|
||||||
|
|
||||||
# Disable colors if output is not a terminal
|
|
||||||
if [ ! -t 1 ]; then
|
|
||||||
RED='' GREEN='' YELLOW='' CYAN='' PURPLE='' BLUE='' GRAY='' BOLD='' RESET=''
|
|
||||||
fi
|
|
||||||
|
|
||||||
color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
|
|
||||||
color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
|
|
||||||
color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
|
|
||||||
color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
|
|
||||||
color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
|
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
# Debug Flag Initialization
|
# Debug Flag Initialization (MUST BE OUTSIDE THE GUARD)
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
clear # Wipes the terminal history view cleanly
|
# We check if $DEBUG_MODE is already true (passed down) or if -d was passed
|
||||||
|
if [[ "${DEBUG_MODE:-false}" == "true" || "${1:-}" == "-d" || "${1:-}" == "--debug" ]]; then
|
||||||
export DEBUG_MODE=false
|
|
||||||
if [[ "${1:-}" == "-d" || "${1:-}" == "--debug" ]]; then
|
|
||||||
export DEBUG_MODE=true
|
export DEBUG_MODE=true
|
||||||
color_red "!!! DEBUG MODE ENABLED !!!"
|
|
||||||
color_red "The script will pause after each major section."
|
|
||||||
echo
|
|
||||||
else
|
else
|
||||||
set -e # Enable immediate exit on error only if NOT debugging step-by-step
|
export DEBUG_MODE=false
|
||||||
|
set -e # Enable immediate exit on error only if NOT debugging
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
# Debug Pause Helper
|
# Debug Pause Helper (MUST BE OUTSIDE THE GUARD)
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
pause_if_debug() {
|
pause_if_debug() {
|
||||||
if [[ "$DEBUG_MODE" == "true" ]]; then
|
if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
|
||||||
echo
|
echo
|
||||||
color_yellow "----------------------------------------------------------------"
|
color_yellow "----------------------------------------------------------------"
|
||||||
read -rp "Section complete. Press [Enter] to continue, or [q] to abort: " debug_choice
|
read -rp "Section complete. Press [Enter] to continue, or [q] to abort: " debug_choice
|
||||||
@@ -62,6 +38,10 @@ pause_if_debug() {
|
|||||||
# GUARD WRAPPER START
|
# GUARD WRAPPER START
|
||||||
# ==========================================
|
# ==========================================
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
clear # Clean screen only when launching the main menu script directly
|
||||||
|
|
||||||
|
color_red "!!! DEBUG MODE ENABLED !!!"
|
||||||
|
color_red "The script will pause after each major section."
|
||||||
|
|
||||||
echo
|
echo
|
||||||
color_yellow "----------------------------------------------------------------"
|
color_yellow "----------------------------------------------------------------"
|
||||||
|
|||||||
Reference in New Issue
Block a user