Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(regen-defs): Fix globs and clean tempfiles on INT, TERM #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions regen-defs.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ for folder in $folders; do
stdout_file=$(mktemp)
stderr_file=$(mktemp)

# Cleanup on interruption
cleanup() {
rm "$stdout_file" "$stderr_file"
}
trap cleanup INT TERM

# Execute the command and capture stdout and stderr
uv run "$cpplint" $cmd > "$stdout_file" 2> "$stderr_file"
eval uv run "$cpplint" $cmd > "$stdout_file" 2> "$stderr_file"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this change things?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes globbing work, since otherwise we literally pass "*" to cpplint, at least on my machine.

ret_code=$?

# Count the number of lines in stdout
Expand All @@ -42,7 +48,7 @@ for folder in $folders; do
} > "$file"

# Clean up temporary files
rm "$stdout_file" "$stderr_file"
cleanup
done
cd ..
done