Skip to content
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

Consider improving the developer experience when using output redirects #20

Open
ezzatron opened this issue Nov 27, 2019 · 1 comment
Open

Comments

@ezzatron
Copy link
Member

Say you have a target like this:

foo:
	some-command > foo

Currently, if you run make foo, and some-command fails, foo will be created, and make will exit with a status of 0. Furthermore, a subsequent run of make foo will claim that foo is up-to-date.

We could improve this situation by setting either SHELL or .SHELLFLAGS to enforce Bash's pipefail option. This will cause make to exit with a non-zero status when some-command fails. Unfortunately the foo file will still be created on error, so this doesn't completely solve the issue. We might also want to consider using .DELETE_ON_ERROR, which should in theory handle this last part of the problem.

@jmalloc
Copy link
Contributor

jmalloc commented Jul 24, 2022

Just some quick and dirty things we could do by convention to at least ensure that the erroneous file doesn't persist:

foo:
	some-command > foo || rm foo
foo:
	output=$$(some-command) && output "$$output" > foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants