make && echo "hello" only print hello when make succeeds (kernel)
For compiling the linux kernel, If I do
make_runner.sh && echo "hello"
it prints hello even if some of the kernel compilation fails.
Is there a way for it to only print if all of the compilation targets built correctly?
Where make_runner.sh
is the following:
#!/usr/bin/env bash
set -xe
make O=out ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- vendor/citrus-perf_defconfig
make O=out ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- -j$(nproc --all) 2>&1 | tee kernel.log
Because of the pipe to tee
, the second make
’s exit status is ignored.
To get the behaviour you want, you need to enable pipefail
: change the set -xe
line to
set -xe -o pipefail
See Debugging scripts, what is the difference between -x to set -euxo pipefail? for details.