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

Re: alias not found

On 10/29/2015 04:53 PM, Bart Schaefer wrote:
On Oct 29,  1:32pm, Ray Andrews wrote:
}     $ . ./navtools; type naliases; naliases
}     naliases is an alias for n_aliases
}     zsh: command not found: naliases

The entire line ". ./navtools; type naliases; naliases" has already
been parsed into bytecode before any of it is executed.  So when
navtools creates the alias, it's too late -- naliases has already
been consumed and is not subject to alias replacement until another
subsqeuent chunk of input is presented to the parser (effectively,
not until after the next PS1 prompt is printed).

This is one reason aliases are a bad idea in general.  It would be
much better if navtools used e.g.

     function naliases { n_aliases "$@" }

Ok, that's one of those little things that's easy to get wrong.
I'm thinking of each command being finished and returned before
the next one is even looked at. Is there some fix for that?
Which is to say, can we force sequential execution? It seems this
sort of thing is only a problem with aliases, or at least that
I've seen so far.

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