zsh-users
 help / color / mirror / code / Atom feed
* { foo=bar; command; } | othercommand; echo $foo == no output?
@ 2001-04-19  3:36 Andre Pang
  2001-04-19  5:10 ` Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Pang @ 2001-04-19  3:36 UTC (permalink / raw)
  To: zsh-users

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@zip.com.au -----

From: waratah@zip.com.au
To: slug-chat@slug.org.au
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@algorithm.com.au>          - trust.in.love.to.save


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: { foo=bar; command; } | othercommand; echo $foo == no output?
  2001-04-19  3:36 { foo=bar; command; } | othercommand; echo $foo == no output? Andre Pang
@ 2001-04-19  5:10 ` Andrej Borsenkow
  0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 2001-04-19  5:10 UTC (permalink / raw)
  To: Andre Pang; +Cc: zsh-users

On Thu, 19 Apr 2001, Andre Pang wrote:

> I have a problem,  I want to tee and still get the return code:
>
>   prog  x y z | tee
>   echo $?
>

In recent enough zsh (4.0.1-pre-3 is the latest version) you can use
$pipestatus:

pipestatus <S> <Z>
     An array containing the exit values returned by all commands in the
     last pipeline.

bor@itsrm2:~%> cat /foo/bar | tee
cat: Cannot open /foo/bar: No such file or directory
bor@itsrm2:~%> print $pipestatus
2 0

-andrej




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-19  5:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-19  3:36 { foo=bar; command; } | othercommand; echo $foo == no output? Andre Pang
2001-04-19  5:10 ` Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).