[clug] Tee eats the return code of the previous entry in the
clug at repose.cx
Tue Mar 9 06:22:42 GMT 2004
Michael Still <mikal at stillhq.com> writes:
> Consider this:
> > cat fail
> exit 1
> > ./fail; echo $?
> > ./fail | tee - /tmp/foo; echo $?
> 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.
mobile% cat > foo
mobile% exit=$((sh foo; echo $?) | tee - /tmp/foo); echo $exit
If the command printed output you could of course just use the last
line of output (since the exit code will be printed after any output
from the app / script.
More information about the linux