9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] multiple inputs
Date: Tue, 30 Mar 2004 19:27:55 +0100	[thread overview]
Message-ID: <6b5dcd845b37ef60c5063f852832aea0@vitanuova.com> (raw)
In-Reply-To: <ff4825e04423f600fb1934d35222f75d@cwru.edu>

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

> fn bt {
> 	eval '{'for {tail -f $i &} '}'
> }
> 
> mimics how I would write it by hand.

if that's all you need, then

fn bt {
	for(i){tail -f $i&}
}

should be just fine.
then

	bt > file

might work (if file is append-only, otherwise you'd need a process
(e.g.  cat) in the middle to avoid overlapping writes)

using eval is disastrous...  consider what happens if you've got a
filename with a shell metacharacter in it.

[-- Attachment #2: Type: message/rfc822, Size: 5882 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 665 bytes --]

I'll agree with you there. The eval is unnecessary.

But 

fn bt {
	eval '{'for {tail -f $i &} '}'
}

mimics how I would write it by hand.

{tail -f file1 &; tail -f file2 &; tail -f file3 &}>file

Which allows me to consider the command one block, which I can pipe to and from etc.

The idiom that you and matt give doesn't work for pipes

tail -f file1 &; tail -f file2 &; tail -f file3 >file

only puts the text from file3 in the pipe. 

The for loop you gave obviates that problem, since it counts as a single block, but it's considerably different than my interactive shell usage and is more verbose(though much more readable :)).

Noah

[-- Attachment #2.1.2: Type: message/rfc822, Size: 3075 bytes --]

From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] multiple inputs
Date: Tue, 30 Mar 2004 17:25:46 +0100
Message-ID: <19236d27e19c4ebbe4ba92e507e29149@vitanuova.com>

> You need to put the brackets on the outside to make the combination of
> tail -f's act like a single 'tail -f'.  That was my real conceptual
> misunderstanding the first time around.

erm, i don't think so.

{a & b &}

should be exactly the same as

a & b &

you almost never need eval in rc, unless you genuinely want
to evaluate an rc expression that's unknown beforehand
(which isn't true in your case).

you could have got the behaviour i think you were after
with something like:

fn bt {
	x=$1
	shift
	for(i) {tail -f $i &}
	tail -f $x
}

  reply	other threads:[~2004-03-30 18:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-30  6:53 npe
2004-03-30  8:22 ` matt
2004-03-30 11:48   ` glenda
2004-03-30 14:03     ` matt
2004-03-30 12:10       ` glenda
2004-03-30 16:07         ` rog
2004-03-30 14:15           ` Noah Evans
2004-03-30 16:25         ` rog
2004-03-30 16:14           ` Noah Evans
2004-03-30 18:27             ` rog [this message]
2004-03-30 16:28               ` Noah Evans
2004-03-31 20:22             ` boyd, rounin
2004-04-01 13:01               ` Noah Evans
2004-04-01 15:31                 ` rog
2004-04-01 14:43                   ` boyd, rounin
2004-04-01 16:26                   ` Russ Cox
2004-04-01 17:36                     ` rog
2004-04-01 15:58                       ` Noah Evans
2004-04-01 18:42                         ` rog
2004-04-01 17:34                           ` Noah Evans
2004-04-01 19:47                             ` rog
2004-04-01 18:02                               ` Noah Evans
2004-04-02  1:48                                 ` Geoff Collyer
2004-04-01 20:04                             ` David Tolpin
2004-04-02  1:46                     ` Geoff Collyer
2004-04-02  2:09 Noah Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b5dcd845b37ef60c5063f852832aea0@vitanuova.com \
    --to=rog@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).