Skip to content

Commit 54ee614

Browse files
Merge pull request #9 from LucaTools/fix/install-interrupt-and-sudo-error-handling
Fix install.sh not aborting on Ctrl+C or sudo failure
2 parents 1ab5e65 + a2b92c5 commit 54ee614

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

install.sh

Lines changed: 8 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).
@@ -210,6 +212,7 @@ echo "🧹 Cleaned up temporary files"
210212
# This checks if the install directory is writable before using sudo
211213
sudo_if_install_dir_not_writeable() {
212214
local command="$1"
215+
local exit_code
213216
if [ -w "$INSTALL_DIR" ]; then
214217
# Directory is writable, run without sudo
215218
sh -c "$command"
@@ -218,6 +221,11 @@ sudo_if_install_dir_not_writeable() {
218221
echo "🔐 Administrator privileges required for installation to $INSTALL_DIR"
219222
sudo sh -c "$command"
220223
fi
224+
exit_code=$?
225+
if [ "$exit_code" -ne 0 ]; then
226+
echo "❌ ERROR: Command failed or was interrupted (exit code: $exit_code)"
227+
exit "$exit_code"
228+
fi
221229
}
222230

223231
# Create install directory if it doesn't exist

0 commit comments

Comments
 (0)