I have a build script in which, at some point, I call
save the output in a variable - and print on error
cmdout=$(make -j4 2>&1)
if ((es)); then
echo >&2 "make error es $es: \"$cmdout\""
echo "make success"