bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: posix command search and execution


From: Chet Ramey
Subject: Re: posix command search and execution
Date: Wed, 8 Nov 2023 10:38:19 -0500
User-agent: Mozilla Thunderbird

On 11/7/23 5:04 PM, Mike Jonkmans wrote:

   | > 1d) Lists 20 fixed utility names (like alias, cd etc.) that are
   | >      to be invoked at his point. No PATH search yet.
   | >       These are the `regular builtins'.
In the next standard the ones listed are the intrinsic builtins,
and includes only those that must be builtin to work.   But
implementations can add more to the list.

Chet mentioned that. But I find the Austin-discussion hard to read.
It makes sense to partition the builtins in three categories with
a separate name for each.

It depends on your requirements. If you want something that is easy to
explain to users, you want to reduce the distinction between `intrinsics'
and `regular builtins' to something as small as possible. That way the
search reduces to

special builtins*
functions
intrinsics
executables

in that order, with ways to override each one (except special builtins
in posix mode).


   | > 1eI) Search is successful.
   | > 1eIa) Check for `regular builtins' and functions
   | >       and invoke that regular builtin/function.
   | >       Q: Shouldn't this specify an ordering for builtins/functions?
   | The text seems to imply that you can't have both, doesn't it?
While I suppose you could have both, it would be very unusual.

Unusuality sketch:
- the shell provides a builtin for a standard utility
- the distributor provides a function for the same utility in /etc/profile
   (maybe to mitigate some security issue)

Are scripts in /etc/profile considered part of the implementation?

Yes. But there's no way to make a distinction between this type of function
and any other user-supplied function, so the distinction isn't useful.


   | Note that this seems to require that you can only run
   | a builtin if it exists (or something with that name exists) in $PATH.
A builtin for a standard utility, yes.

The standard doesn't explicitly make that distinction.


I already can't find the definition of standard utilities.

The standard utilities are the ones specified in the standard.



   | I think the resolution to interpretation 854 addresses this. Shells
   | who want this ordering just declare all the builtins they implement as
   | `intrinsic' so they're not subject to a PATH search.
Yes.

Can this intrinsic list be amended with any user loaded builtins?

You mean enable -f? It's up to the shell implementation. Bash treats
dynamically-loaded builtins the same as any other builtin.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]