install: use EXIT trap for temp directory cleanup#2380
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the installer’s temporary directory cleanup to be centralized and reliable across all exit paths, aligning with the script’s set -e behavior and reducing duplicated cleanup logic.
Changes:
- Registers a single
trap ... EXITimmediately after creating themktemp -ddirectory. - Removes multiple scattered
rm -rf "$TMP_DIR"calls from individual error/success paths. - Ensures cleanup occurs for failures during download, validation, extraction, chmod, and install directory creation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0457b9c to
b92f4e4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace scattered rm -rf calls with a single EXIT trap to ensure the temp directory is always cleaned up on exit. Previously, failures in curl/wget download, tar extraction, chmod, or mkdir left temp files behind because set -e would exit before reaching manual cleanup calls. The trap fires on any exit (success or failure), so it covers all paths with one line while removing five redundant cleanup calls.
b92f4e4 to
177b637
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The install script creates a temp directory with
mktemp -dbut relies on manualrm -rfcalls scattered across individual error handlers to clean it up. Several exit paths are missing cleanup entirely:curl/wgetdownload failure (set -eexits before any cleanup)tarextraction failurechmodfailuremkdir -pfailure (handled error path, but norm -rf)This replaces all five manual
rm -rf "$TMP_DIR"calls with a singletrap ... EXITregistered immediately after the temp directory is created. The trap fires on any exit—whether fromset -e, an explicitexit 1, or normal completion—so every path is covered with one line.Before: 5 cleanup calls, 4+ uncovered exit paths
After: 1 trap, 0 uncovered exit paths