Q:

Output input if it doesn't contain specific String

I have what seems to be a rather simple problem, but I can't find an answer to it.
I'm working on a travis script which validates files.
I'm using 3rd party software for this and therefore I have no influence on the development.
The Problem:
As you may know travis scripts require non-zero exit codes for the build to fail. Unfortunately the software I'm using only outputs error message in stdout but still exists with code 0.
My idea was to use grep.
Currently I'm using this command:
! echo "SomeInput" | grep -Pzo "\A[^\x{0000}]*error message[^\x{0000}]*\Z"
If the error message is printed, it returns with a non-zero exit code and prints the error message.
As you may have noticed, the output is not being displayed when no errors show up. This is bad if we want to check if a paricular change introduced warnings. Which will then also not be displayed.
Any ideas?

A:

If I understand correctly, you want to detect errors by grep-ing certain patterns in the output, and at the same time you also want to see the entire output. The tricky part is that grep itself would consume the output.
I don't there's an easy clever solution for this. You need to consume the output twice. Once to just print it, and one more time to check for errors.
One solution is to save the output to a file first, and then process it. For example:
some_command 2>&1 | tee out.log
! grep -Pzo "\A[^\x{0000}]*error message[^\x{0000}]*\Z" out.log

