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

Re: priority of execution




On 2022-10-25 09:08, Peter Stephenson wrote:
The different categories known to whence, from looking at the source,
are aliases, reserved words, shell functions, builtins, and binaries
in the file system (in the case of whence, those found via $PATH).
In that order?
Autoloadable functions are a special category of function

But whence reports them specially:

$ whence -v zmv
zmv is an autoload shell function

... I'm just trying to extract as much information as whence can supply.

--- the
difference only comes into play once the shell has decided it's
looking for a shell function, so it's hidden from top-level
execution.
So when it comes to precedence would a 'normal' function and an autoload, if they shared the ... Ah! the can't share the same name because if you define a function with the same name as an autoload the former is ... how to say it ... overruled.  So that's no issue. But whence will report the difference very politely.
The same goes for shell scripts as a special category of
binaries found in the file system.  The shell sees the script is
a binary in the path and tries to execute it just like anything
else marked as executable.  Typically the OS knows how to deal
specially with scripts, though the shell has this knowledge as
a fallback.

So it would be first found, first executed?  Or will there be precedence rules?


$ whence -av declare
declare is a reserved word
declare is a shell builtin
That second case is rather special; you wouldn't encounter it very
often.  But people moan horribly if we break their special cases.

Too heavy for me, that's stuff than only happens in the engine room.

But I'd still say that this should be the output:

$ whence -v declare

declare is a shell builtin

... it might be naive but that's what would seem to be the ... hmmm ... if 'reserved word' really does have precedence then maybe that's what's got to show, and the fact that I want to see 'shell builtin' is too bad for me.  It's intuitive that whence is looking for commands of some sort, but maybe strictness is more important.  Nothing is simple.








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