<<< Date Index >>>     <<< Thread Index >>>

Re: Changing Headers in the Compose screen



On Tue, Jan 20, 2004 at 11:32:38PM EST, David Champion wrote:
> * On 2004.01.20, in <20040121041846.GG26679@xxxxxxx>,
> *     "David Yitzchak Cohen" <lists+mutt_users@xxxxxxxxxxxxxx> wrote:

> > BTW - For a file less than 4096 bytes long, you can do this instead:
> > cat < file | filter | cat > file
> > as long as filter doesn't attempt to flush its output.  (The pipe buffers
> > hold all the intermediate data.)
> > 
> > For files of arbitrary length, you can replace the UNIX pipe buffer with
> > a small little program:
> > filter <file | read_everything_into_memory_and_spit_back_everything_on_eof 
> > >file
> 
> Kids, don't try this at home. This depends totally on the shell in
> use, not on cat or r_e_i_m_a_s_b_e_o_e.

What's that?

> Every shell I've tried this
> sort of thing in implements pipelines in a certain unixy way: i.e.,
> output streams must be opened before programs are executed, and the last
> stage of a a pipeline executes before the first. (Pipelines execute
> right-to-left.)

That's interesting ... I use plain old bash, and have done the above
successfully ... weird. . .

> This means that pretty much every shell is going to
> overwrite your input file before anyone gets to read it. If anything
> else happens, it's a scheduler fluke, and certainly not reliable.

That's really interesting.  I use the standard Linux scheduling algorithm,
nothing special.  The only remotely "interesting" feature of my system is
that it's got two CPUs, but most of the "fun stuff" I encounter happens
in multithreaded apps only.

Here, let's have some fun:

$ for blah in `seq 1 1000` ; do echo blah > temp.ttt ; cat < temp.ttt | sed 
's/blah/goo/' | cat | cat | cat > temp.ttt ; cat temp.ttt ; rm -f temp.ttt ; 
done | wc -l
    862

For some reason, having only two cat(1)s doesn't do the trick nearly
as often, but you'll notice that with three cat(1)s, we get the filter
executed "in-place" more than 85% of the time - not too bad, eh?

 - Dave

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgpCYrLT0BRPV.pgp
Description: PGP signature