From 617fbec3d2e85ecf614e9ee6eed172f873e67983 Mon Sep 17 00:00:00 2001 From: Alberto De Bortoli Date: Thu, 26 Mar 2026 21:33:11 +0000 Subject: [PATCH 1/2] Abort installation on SIGINT (Ctrl+C) Without a trap, pressing Ctrl+C during a sudo password prompt does not terminate the script. sudo catches SIGINT internally to restore terminal state and exits with a non-zero code, but bash never sees a signal-killed child and continues execution. Registering a trap on INT ensures the script always exits with code 130 (the conventional code for SIGINT-terminated processes) regardless of how the signal is handled by child processes. --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index fd90ff7..77d14e0 100755 --- a/install.sh +++ b/install.sh @@ -25,6 +25,8 @@ POST_CHECKOUT_HOOK_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/ # GITHUB API AUTHENTICATION # ============================================================================= +trap 'printf "\nโŒ Installation interrupted.\n"; exit 130' INT + # Build curl options for GitHub API requests. # If GITHUB_TOKEN is set, include it as a Bearer token to avoid rate limiting # (5000 req/hr authenticated vs. 60 req/hr unauthenticated). From a2b92c537b23424302ed83a6f078396082e8a23f Mon Sep 17 00:00:00 2001 From: Alberto De Bortoli Date: Thu, 26 Mar 2026 21:33:30 +0000 Subject: [PATCH 2/2] Abort installation on sudo or command failure in sudo_if_install_dir_not_writeable The function silently returned non-zero exit codes to callers (wrong password, missing source file, permission denied, etc.), which allowed the script to continue in a broken state. Capturing $? immediately after the command and calling exit preserves the original exit code and ensures any failure stops the installation with a clear error message. --- install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install.sh b/install.sh index 77d14e0..1acccf4 100755 --- a/install.sh +++ b/install.sh @@ -212,6 +212,7 @@ echo "๐Ÿงน Cleaned up temporary files" # This checks if the install directory is writable before using sudo sudo_if_install_dir_not_writeable() { local command="$1" + local exit_code if [ -w "$INSTALL_DIR" ]; then # Directory is writable, run without sudo sh -c "$command" @@ -220,6 +221,11 @@ sudo_if_install_dir_not_writeable() { echo "๐Ÿ” Administrator privileges required for installation to $INSTALL_DIR" sudo sh -c "$command" fi + exit_code=$? + if [ "$exit_code" -ne 0 ]; then + echo "โŒ ERROR: Command failed or was interrupted (exit code: $exit_code)" + exit "$exit_code" + fi } # Create install directory if it doesn't exist