On Saturday 04 August 2007 15:45:56 Loïc Grenié wrote:
> 2007/8/4, Alexander Kriegisch <[EMAIL PROTECTED]>:
> > I would like to determine the exit code of 'foo' in
> > foo | bar
> >
> > I bash there is the PIPESTATUS array, but in ash (which I must use)
> > there is no such thing as PIPESTATUS or arrays. Is there any canonical
> > way or at least a workaround to achieve both piping the foo's output
> > into bar unconditionally *and* determining foo's exit code?
> 
> x=`((( foo 3>&- 4>&- ); echo $? >&3)| bar >&4  3>&- 4>&-) 3>&1` 4>&1
> 
>   should do the trick. The exit code of foo is in x, the output of bar
>   goes to the output of the command.
> 
>       Hope this helps.
> 
>          Loïc

foo > out.file
ret=$?
cat out.file | bar
# rm out.file

Untested. Just an idea...........

Ciao,
Tito
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to