fix: add trap to clean up temp directory on unexpected exit#1
Open
AnveshKolluri wants to merge 1 commit into
Open
fix: add trap to clean up temp directory on unexpected exit#1AnveshKolluri wants to merge 1 commit into
AnveshKolluri wants to merge 1 commit into
Conversation
install.sh uses \set -e\ which terminates the script on any command failure. When this happens (e.g., download 404, network error), the temp directory created by \mktemp -d\ is never cleaned up because the manual \ m -rf\ calls only cover explicitly handled error paths. Add a \ rap ... EXIT\ immediately after creating the temp directory to ensure cleanup on all exit paths. This also removes the now- redundant manual cleanup calls, simplifying the error handling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Ensures install.sh always cleans up its mktemp -d directory even when set -e causes an implicit/early exit (e.g., failed downloads).
Changes:
- Add an
EXITtrap immediately after creatingTMP_DIRto remove the temp directory on all exit paths. - Remove now-redundant manual
rm -rf "$TMP_DIR"cleanups from individual error/success branches.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
install.shusesset -ewhich terminates the script on any command failure.When this happens (e.g., download 404, network error), the temp directory
created by
mktemp -dis never cleaned up — it's leaked in/tmp.The existing
rm -rf "$TMP_DIR"calls only cover manually handled error paths,but
set -eimplicit exits bypass all of them.Repro: