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

Re: echo > * and EMFILE



Bart Schaefer wrote:
> The next question is what is best from the user's point of view.
> Suppose the example were something like
> 
> 	print $SECONDS > *
> 
> If we call zerr() and closemnodes(), then an error message is printed
> once but the command never actually executes, so the files that it was
> possible to open are truncated to zero size.   If we call zwarn() and
> not closemnodes(), then hundreds of error messages are printed, the
> command goes ahead, some files get $SECONDS and some remain unchanged.
> Which is preferable?

Probably the former.  Failing to open an output channel should in general
be a fatal error, at least for the command that's executing.  That seems
to be how it works currently:

% { echo foo; echo Done 1 >&2; } >/noaccess; echo Done 2
zsh: permission denied: /noaccess
Done 2

Multios have the inevitable property that a failure can't be atomic,
i.e. you can't necessarily have either the state before, or a success.
I think we just have to live with aborting as early as possible as a
bit better than getting further but still not doing what the user
asked.  In the case of a warning you don't even get a non-zero status,
so in a function or script---even a carefully written one designed to
bail out at the first sniff of an error---you might not notice until far
too late.  (How careful a script or function actually is if it's so
cavalier with multios is another question.)

However, what the user actually wants depends on the context, so it's
possible you can come up with cases where the other alternative is
better.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



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