Today I was working on a build script where I only wanted output if there were
failures (syntax errors, failing tests, lint errors etc…).
Most people when encountered with this are probably used to doing the 2>&1
hacks to silence expected output.
Or atleast more readable…
In the moreutils package which you probably already have on your machine
(If not you can do sudo apt install moreutils) is a tasty little number
called chronic (I’m also a fan of vidir but we’ll leave that for another
sudo apt install moreutils
chronic will only display any output if it exited with a non-zero exit status.
This is useful for build scripts and the like where you don’t want noise unless
Running it is as simple as prefixing your command with chronic.
phpunit --group myTestSuite
chronic phpunit --group myTestSuite
Enjoy your cleaner build scripts!