Skip to content

Commit 617fbec

Browse files
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.
1 parent 1ab5e65 commit 617fbec

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ POST_CHECKOUT_HOOK_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/
2525
# GITHUB API AUTHENTICATION
2626
# =============================================================================
2727

28+
trap 'printf "\n❌ Installation interrupted.\n"; exit 130' INT
29+
2830
# Build curl options for GitHub API requests.
2931
# If GITHUB_TOKEN is set, include it as a Bearer token to avoid rate limiting
3032
# (5000 req/hr authenticated vs. 60 req/hr unauthenticated).

0 commit comments

Comments
 (0)