zsh-users
 help / color / mirror / code / Atom feed
* alias not found
@ 2015-10-29 20:32 Ray Andrews
  2015-10-29 23:53 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Ray Andrews @ 2015-10-29 20:32 UTC (permalink / raw)
  To: Zsh Users

Working with Sebastian's tools I do this:

    $ . ./navtools; type naliases; naliases
    naliases is an alias for n_aliases
    zsh: command not found: naliases


... strange that the alias isn't found since it is part of the code in 
'navtools' and 'type' sees it.  If I immediately rerun the alias, it's 
fine.  Any ideas?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: alias not found
  2015-10-29 20:32 alias not found Ray Andrews
@ 2015-10-29 23:53 ` Bart Schaefer
  2015-10-30  3:16   ` Ray Andrews
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-10-29 23:53 UTC (permalink / raw)
  To: Zsh Users

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 "$@" }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: alias not found
  2015-10-29 23:53 ` Bart Schaefer
@ 2015-10-30  3:16   ` Ray Andrews
  2015-10-30  4:56     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Ray Andrews @ 2015-10-30  3:16 UTC (permalink / raw)
  To: zsh-users

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: alias not found
  2015-10-30  3:16   ` Ray Andrews
@ 2015-10-30  4:56     ` Bart Schaefer
  2015-10-30  6:00       ` Ray Andrews
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-10-30  4:56 UTC (permalink / raw)
  To: zsh-users

On Oct 29,  8:16pm, Ray Andrews wrote:
}
} 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?

Well, no.  That would be Gromit laying his railroad tracks.

} It seems this sort of thing is only a problem with aliases, or at
} least that I've seen so far.

Aliases are one of those things like "setopt interactive_comments"
that actually changes the parsing.

torch% setopt interactivecomments; echo # this is not a comment
# this is not a comment


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: alias not found
  2015-10-30  4:56     ` Bart Schaefer
@ 2015-10-30  6:00       ` Ray Andrews
  0 siblings, 0 replies; 5+ messages in thread
From: Ray Andrews @ 2015-10-30  6:00 UTC (permalink / raw)
  To: zsh-users

On 10/29/2015 09:56 PM, Bart Schaefer wrote:
> Well, no.  That would be Gromit laying his railroad tracks.

Really?  I can see that 'line at a time' parsing would be a desired 
thing. But if
I can avoid the occasional problem by returning to a fresh prompt, it would
seem possible to have the same functionality via some other mechanism.
Mind, everything up to a sem has to be syntactically complete of course,
so none of the mayhem we were talking about a while back.
OTOH since this is the first time I've ever seen any issue of this sort,
I can quite understand that there's not much call for it.  In my case it
would simply let me get more done with a single recallable line like I first
showed.
> } It seems this sort of thing is only a problem with aliases, or at
> } least that I've seen so far.
>
> Aliases are one of those things like "setopt interactive_comments"
> that actually changes the parsing.
>
> torch% setopt interactivecomments; echo # this is not a comment
> # this is not a comment

I've heard of that and I'm afraid to even think about what it does. Anyway,
these are good cautions about aliases.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-30  6:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 20:32 alias not found Ray Andrews
2015-10-29 23:53 ` Bart Schaefer
2015-10-30  3:16   ` Ray Andrews
2015-10-30  4:56     ` Bart Schaefer
2015-10-30  6:00       ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).