|
藍森林 http://www.lslnet.com 2006年6月26日 11:18
請教關於返回值和標準輸出的問題..進內看詳細
a.sh如下
----------
echo "test"
return 1
------------
b.sh
-----------
sh a.sh | tee -a /tmp/log
if [ $? -eq 0 ] ;
then
....
if
--------------
在b.sh中我現在想根據 a.sh返回值來做一些操作。便是 $?得到的值是 tee的.不是a.sh的..請問有什麼辦法解決這個問題嗎?在線等.謝了 |
[color=red]==>[/color] [url=http://www.lslnet.com/linux/#viewthread.php?tid=551026&page=1#pid3647972][color=blue][u]RTFM[/u][/color] |
請幫忙解釋一下...
exec 3>&1
eval `
# now, inside the `...`, fd4 goes to the pipe
# whose other end is read and passed to eval;
# fd1 is the normal standard output preserved
# the line before with exec 3>&1
exec 4>&1 >&3 3>&-
{
cmd1 4>&-; echo "ec1=$?;" >&4
} | {
cmd2 4>&-; echo "ec2=$?;" >&4
} | cmd3
echo "ec3=$?;" >&4
`
請問 exec 3>&1, exec 4>&1 >&3 3>&1 中的意思是什麼?完全看不明白..請高手指點一下..多謝 |
| |