Say I have the following files:
buggy_program:
#!/bin/sh echo "wops, some bug made me exit with failure" exit 1
Makefile:
file.gz: buggy_program | gzip -9 -c >$@
Now if I type make
, GNU make will happily build file.gz
even though buggy_program
exited with non-zero status.
In bash I could do set -o pipefail
to make a pipeline exit with failure if at least one program in the pipeline exits with failure. Is there a similar method in GNU make? Or some workaround that doesn't involve temporary files? (The reason for gzipping here is precisely to avoid a huge temporary file.)
Try this
SHELL=/bin/bash -o pipefail file.gz: buggy_program | gzip -9 -c >$@
You could do:
SHELL=/bin/bash .DELETE_ON_ERROR: file.gz: set -o pipefail; buggy_program | gzip -9 -c >$@
but this only work with bash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With