-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix cleanup of temporary files #1227
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
base: main
Are you sure you want to change the base?
Conversation
| fi; \ | ||
| if [ "$$should_install" = 'yes' ]; then \ | ||
| echo "... installing $(COMMAND)"; \ | ||
| head -1 bin/$(COMMAND) > $(TEMPFILE); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about building the script content in a subshell and redirecting it directly to the destination? This avoids mktemp, chmod on temp files from the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this?
- source the
helper/scripts rather than embedding them- add the source command to each script in
bin/
- add the source command to each script in
- install the
helper/scripts in/usr/share/git-extras/helperor similar - separate out a
buildtarget from theinstalltarget - build each of the to-be-installed scripts in a pattern rule that would just add the install path for the
helper/scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this plan a little complicated? We can just use the subshell's stdout as a temp file, so no need to use a real file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander Could we keep using the temporary file? Things kind of look complicated enough with this being embedded in a Makefile and all,.
hyperupcall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far! Was a little bothersome to learn that git-extras didn't cleanup properly after execution.
Just had a few minor comments; once addressed, I'll approve!
| fi; \ | ||
| tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ | ||
| cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ | ||
| rm -f $(TEMPFILE); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're adding this, could this go after the @foreach and before the @if [ -z "$(wildcard man/git-*.1)" ]; then \? The temporary file is created outside of the loop, not inside,.
| fi; \ | ||
| if [ "$$should_install" = 'yes' ]; then \ | ||
| echo "... installing $(COMMAND)"; \ | ||
| head -1 bin/$(COMMAND) > $(TEMPFILE); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander Could we keep using the temporary file? Things kind of look complicated enough with this being embedded in a Makefile and all,.
|
|
||
| set -euo pipefail | ||
|
|
||
| proceed=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved out to a separate PR? For matching the argument, would prefer using $1 == @(--proceed|-p) (enabling extglob) or keeping the existing structure and using group commands ({ true && true; }) instead of subshells.
|
|
||
| if [[ -n "$DEBUG" ]] ; then | ||
| sort -nr "$DEBUG" && | ||
| rm -f "$DEBUG" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't DEBUG not be removed, so that the user could see the debug output after git guilt runs?
No description provided.