rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* optimal scripts
@ 1992-07-09 22:08 Brendan Kehoe
  1992-07-10 15:29 ` Y-shaped pipeline Mark-Jason Dominus
  0 siblings, 1 reply; 4+ messages in thread
From: Brendan Kehoe @ 1992-07-09 22:08 UTC (permalink / raw)
  To: rc mailing list


What's the fastest (most efficient) way to do something like this?

	for (foo in $bar) {
	   if ( some_test $foo ) {
		first=($first $foo);
	   } else {
		second=($second $foo);
	   }
	}

Brendan


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

* Y-shaped pipeline
  1992-07-09 22:08 optimal scripts Brendan Kehoe
@ 1992-07-10 15:29 ` Mark-Jason Dominus
  0 siblings, 0 replies; 4+ messages in thread
From: Mark-Jason Dominus @ 1992-07-10 15:29 UTC (permalink / raw)
  To: rc mailing list; +Cc: mjd


I have a program, `why', which expects to write output
to file descriptors 4 and 5.  

	why >[4] descriptor-four-log >[5] descriptor-five-log

works fine; the data that `why' writes to desriptor 4 winds up in
`descriptor-four-log', and the data that `why' writes to descriptor 5
goes to the file `descriptor-five-log'.

Now I want the descriptor 4 data to be piped into the stdin of some
command, say `rev', and I want the descriptor 5 data to be piped into
another command, say `cat -n'.  This doesn't work:

	why |[4] rev |[5] cat -n

because that means to connect descriptor 4 of `why' to descriptor 0 of
rev, and then to connect descriptor 5 of rev to descriptor 0 of cat -n.

How can I connect a command to two pipes at once?




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

* Re: Y-shaped pipeline
  1992-07-10 16:35 haahr
@ 1992-07-10 22:53 ` Chris Siebenmann
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Siebenmann @ 1992-07-10 22:53 UTC (permalink / raw)
  To: rc

 I thought the natural way to do it would be with '.... >[N]{command}',
but that doesn't seem to work. A pity. Anyone care to fix things so it
does?

	- cks


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

* Re: Y-shaped pipeline
@ 1992-07-10 16:35 haahr
  1992-07-10 22:53 ` Chris Siebenmann
  0 siblings, 1 reply; 4+ messages in thread
From: haahr @ 1992-07-10 16:35 UTC (permalink / raw)
  To: mjd, rc

{ why |[4] rev } |[5] cat -n
# this does mean that the stdout of rev and cat will be intermixed
# and you should hope that rev doesn't put anything out on fd 5.


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

end of thread, other threads:[~1992-07-10 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-07-09 22:08 optimal scripts Brendan Kehoe
1992-07-10 15:29 ` Y-shaped pipeline Mark-Jason Dominus
1992-07-10 16:35 haahr
1992-07-10 22:53 ` Chris Siebenmann

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).