Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

{ foo=bar; command; } | othercommand; echo $foo == no output?



g'day all,

a mate is maving a problem with the following, and i tried the
behaviour under zsh and it doesn't work either.  is there a
reason why this doesn't work?  and what would be a good
solution?  (i suggested setopt multios; prog x y z > /dev/stdout
> filename)

thanks zsh gurus!


----- Forwarded message from waratah@xxxxxxxxxx -----

From: waratah@xxxxxxxxxx
To: slug-chat@xxxxxxxxxxx
Date: Thu, 19 Apr 2001 01:59:54 GMT
Subject: [slug-chat] Script challenge with tee
Envelope-to: andrep@localhost
X-Mailer: Endymion MailMan Standard Edition v3.0.26


I have a problem,  I want to tee and still get the return code:

  prog  x y z | tee
  echo $?

Will always show zero because this is the return code of tee.  I need the 
return value of prog.

{
  prog x y z
  echo $?
} | tee

works but I want to capture the values so that I can exit much later with the 
value of this program.

{
   prog x y z
   RC=$?
}  | tee

  lp ...

exit $RC

RC is does not appear to be available to the script.

Any suggestions?

KenF

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/



-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug-chat


----- End forwarded message -----

-- 
#ozone/algorithm <ozone@xxxxxxxxxxxxxxxx>          - trust.in.love.to.save



Messages sorted by: Reverse Date, Date, Thread, Author