1

I have a make file that includes:

%.dat: %.txt
   ... PREPROCESSING OF TEXT FILE
   tidy -o $*.html $<
   ... FURTHER PROCESSING

tidy produces lots of warnings that I can suppress with the flag --show-warnings false, but despite supressing the warnings, the exit status from tidy still 1 instead of 0, and so make fails part way through the recipe. How can I have make continue in the face of tidy giving exit status 1 while still allowing make to fail if any other recipe gives warnings?

I have looked at these two question (Have make fail if unit tests fail and gcc, make: how to disable fail on warning?) but neither seems to deal with this problem.

AFTER EDIT: In Make: how to continue after a command fails?, the question relates to how one gets make to continue after any non-zero exit status in executing a particular command, whereas in my case, I want an exit status of 2 from tidy indicating errors, to cause make to fail, but I want an exit status of 1 from tidy, indicating warningsto allowmake to continue`.

CrimsonDark
  • 661
  • 9
  • 20
  • 1
    Possible duplicate of [Make: how to continue after a command fails?](https://stackoverflow.com/questions/2670130/make-how-to-continue-after-a-command-fails) – Mike Kinghan Feb 10 '19 at 10:53
  • I've edited the question to distinguish it from the suggested duplicate. – CrimsonDark Feb 10 '19 at 23:09

1 Answers1

2

The simpliest solution:

tidy -o $*.html $< || true

So if tidy's exit code isn't zero the true produces zero exit code.

But check the tidy's exit codes:

Exit Status

0

All input files were processed successfully.

1

There were warnings.

2

There were errors.

Maybe you want skip only the error code 1. In this case:

tidy -o $*.html $< || [ $$? -eq 1 ] && true
uzsolt
  • 5,832
  • 2
  • 20
  • 32
  • Nice. The general lesson I take from this (I hope correctly) is to devise a shell command, incorporating the critical recipe parts, sot that the shell command produces the correct error code structure. – CrimsonDark Feb 10 '19 at 11:49