使用tee时获取exitcode

当使用tee时,程序的exitcode无法正常获取,比如a.out的exitcode为1,但是使用tee之后得到的为0。这时可以使用set -o pipefail,如下:

./a.out | tee
echo $? # 0

set -o pipefail
./a.out | tee
echo $? # 1



Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • MNN模型支持:Qwen3-VL
  • 一图读懂Qwen
  • 端侧LLM硬件系列(二):内存容量
  • Qwen3-Next:下一代MoE模型架构解析
  • MNN模型支持:面壁小钢炮MiniCPM-V-4