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

Re: Tip of the day: previous command output

On Fri, 20 Aug 2004, Bart Schaefer wrote:

> On Fri, 20 Aug 2004, Andy Spiegl wrote:
> > What would be the difference if I dropped alias with the noglob and used 
> > $* instead of $~*?  I guess zsh would expand the globs before calling 
> > the function, right?
> Right.
> >  But the result should be the same or not?
> Should be the same.  Waiting to expand uses a little less memory.

I just thought of another difference ... and remembered the reason that I 
did it the way I did.


    keep () {
        kept=()         # Erase old value in case of error on next line
        print -Rc - $kept

Without the noglob, and if you use the NO_MATCH or CSH_NULL_GLOB setopts, 
which I do, then globbing errors occur before the function is called, and 
thus prevent the function from being called.  With the noglob alias, the 
globbing error occurs inside the function, at the second assignment.  The 
distinction is that in the latter case the prevous value of kept is erased 
on a globbing error, whereas in the former case it retains its old value.

I find that having kept set to empty on a glob failure is more useful, but
you may prefer otherwise.

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