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: Tue, 7 Nov 2023 11:49:25 -0500
User-agent: Mozilla Thunderbird

On 11/7/23 8:54 AM, Mike Jonkmans wrote:
Thanks for the answers, Chet.

On Mon, Nov 06, 2023 at 02:28:24PM -0500, Chet Ramey wrote:
On 11/6/23 10:48 AM, Mike Jonkmans wrote:

   Q: Why check for regular builtins? That was already done in 1d.
Implementations can provide other builtins. The check in 1d is only for
those specific ones.

It was my earlier understanding that POSIX partitions the builtins into:
- special builtins
- regular builtins (listed in 1d).
- ordinary builtins (i.c. not the two others)
Because the first two are specific lists.

I think the list in 1d defines a particular subset of regular builtins,
and that regular builtins are just non-special ones built into the shell,
as you conclude below:

Upon rereading those, I think it is more like:
- special builtins
- regular builtins listed in 1d
- regular builtins


Which still exists in the new draft standard. They're just called
`intrinsics' now, and the benefit is that shells can define anything
they want as an intrinsic utility.

Look at https://www.austingroupbugs.net/view.php?id=854 for a discussion
of this issue.

Thanks for the link, I find that very hard to read though.

It's also incomplete; there was a lot of discussion on the mailing list.
I don't have a link to a usable public mailing list archive.

...
Thus in posix mode, bash does not follow this part of the standard.
Exactly which part of the standard are you saying bash is not following?

That would be PATH search failing and executing a builtin.

Yes, that's true, but no shell implements things that way, so it's a
deficiency in the standard.

Though i think that standard utilities *must* be in PATH,
otherwise there is no conformance a priori.

That section doesn't restrict itself to the standard utilities.

They should be named 'forever builtins', like 'forever chemicals'.
It's a real shame. There certainly are use cases for overriding the
special builtins (e.g. logging around `.' a.k.a. source).

People override `exit' as well.


- Regarding 1eIb.
    The shells posh, dash, ksh and zsh
    also run builtins, even when not found in PATH.
    Checked with the `test' builtin (mv /usr/bin/test{,.sav})
    on the versions found on Ubuntu 22.04.
Yes, this is part of the discussion of interp 854. The business of running
builtins other than the ones listed only after a PATH search was always
ahistorical.

Hmm, my check maybe incorrect.
Removing the standard utility `test' is not conformant.

You don't have to remove it, just verify that any builtin is run even if
there's no corresponding utility in $PATH. But this is all cleaned up if
the shell defines the builtin as an intrinsic utility.


Then again, is there a requirement for the standard utilities to be
found in the current PATH? Or do they just need to be present somewhere.

They have to be findable using the value returned by `getconf PATH'. If
the user modifies PATH to, say, prepend directories before that standard
PATH, then all bets are off.


- The 'newgrp' utility (mentioned in 1d) is not a builtin in bash.

It's gone in the latest draft of the next version of the standard anyway.


- Utilities:
    https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html
    Q: Where is `standard utilities' defined - as used in 1d.
These are the standard utilities.

Some of these utilities are marked with optional `codes'.
Are these also considered standard utilities - even when the option is
not true?

Not really, no. If the implementation claims to support, for instance, XSI,
the XSI-shaded utilities have to be present and they have to behave as
specified. If the implementation doesn't, they don't.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_04

So in 1d, if the system doesn't claim XSI conformance, the shell doesn't
have to include type or ulimit in this required invocation order.

(But wait! The list of intrinsics in the latest draft includes type and
ulimit, and isn't XSI-shaded. So that will change.)

Chet
--
``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]