分类:
2009-05-23 23:03:18
有脚本如下:
1: make all | tee log
2: ???? # How to get the exit code of command 'make'?
由于在编译的时候想看到编译进度,所以这里用了 tee, 而没用重定向。
在第二行代码处,想知道make是否成功了。
不知该如何实现?
To know the exit status of the elements of a pipeline
cmd1 | cmd2 | cmd3
The exit codes are provided in the PIPESTATUS special array.
cmd1 exit code is in ${PIPESTATUS[0]}, cmd3 exit code in
${PIPESTATUS[2]}, so that $? is always the same as
${PIPESTATUS: -1}.