On Tue Aug 2, 2022 at 12:19 PM EDT, Alejandro Colomar wrote: > On 8/2/22 17:51, DJ Chase wrote: > > You could swap mandoc’s stderr and stdout, then filter it with sed and > > redirect sed to stderr: > > > > mandoc -W <level> 3>&2 2>&1 1>&3 | sed '/reg/ex/d' >&2 > > > > Of course if mandoc also normally writes to stdout this would create new > > stuff on stderr, so you could run it in two-passes: > > > > # pass where we care about mandoc’s regular output > > mandoc 2>/dev/null > > # pass where we care about mandoc’s errors > > mandoc -W <level> 2>&1 >/dev/null | sed '/reg/ex/d' >&2 > > > > (https://stackoverflow.com/questions/13299317/) > > mandoc(1) seems to always write to stdout in -Tlint mode, so this > wouldn't be an issue. > > The issue is the EXIT STATUS. Anything non-zero makes make(1) stop > running and error with 2. That's the hardest thing to workaround.
Would this work: OUTPUT="$(mandoc -Tlint || true)" OUTPUT="$(printf %s\\n "$OUTPUT" | sed '/reg/ex/d')" if [ "$OUTPUT" ]; then printf %s\\n "$OUTPUT" exit 1 fi Cheers, -- DJ Chase They, Them, Theirs