diff --git a/install.sh b/install.sh index fd90ff7..1acccf4 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). @@ -210,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" @@ -218,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