Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
edited tags
Link
Jander
  • 17.1k
  • 6
  • 56
  • 67
Source Link
Lorin Hochstein
  • 8.6k
  • 18
  • 55
  • 56

.DELETE_ON_ERROR behavior with make and pipelines

The .DELETE_ON_ERROR target will tell make to delete a target if a rule fails. But this doesn't work for pipelines, because the exit status value $? holds the value of the last program in the pipeline. As an example, the following makefile will not delete the newly created file foo.

.DELETE_ON_ERROR: foo: false | true > foo 

Is there a way to get make to consider the rule as having failed if any of the programs in the pipeline fail (i.e., if there's a non-zero value in any of the elements of the $PIPESTATUS array)?