[clug] Tee eats the return code of the previous entry in the pipeline

Michael Still mikal at stillhq.com
Tue Mar 9 06:18:40 GMT 2004


Consider this:

 > cat fail
#~/bin/bash
exit 1
 > ./fail; echo $?
1
 > ./fail | tee - /tmp/foo; echo $?
0

This makes me very sad. I want to be able to run a command, dump it's 
output to a file and to the console (in real time), and still have 
access to it's return code.

Anyone have any suggestions as to how I might go about achieving that?

Thanks,
Mikal

-- 

Michael Still (mikal at stillhq.com) | "All my life I've had one dream,
http://www.stillhq.com            |  to achieve my many goals"
UTC + 11                          |    -- Homer Simpson



More information about the linux mailing list