Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173669
  • 博文数量: 24
  • 博客积分: 1575
  • 博客等级: 上尉
  • 技术积分: 235
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-28 22:51
文章分类

全部博文(24)

文章存档

2016年(1)

2013年(1)

2012年(5)

2011年(9)

2010年(2)

2009年(5)

2008年(1)

我的朋友

分类:

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}.
阅读(1202) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~