[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: |
Fri, 10 Nov 2023 20:03:47 -0500 |
User-agent: |
Mozilla Thunderbird |
On 11/9/23 8:21 AM, Mike Jonkmans wrote:
I see. Weirdly on Ubuntu 22.04, with /bin symlinked to /usr/bin,
`getconf PATH' produces `/bin:/usr/bin'.
That looks like a recipe for redundant `stats'.
Does that matter? The value getconf returns is static, and is guaranteed
to find all the standard utilities regardless of what the file system
looks like.
Maybe it matters.
If I am not mistaken, for POSIX compliance, both /bin and /usr/bin have
to be in PATH (see quote from Robert).
No, POSIX doesn't have anything to do with actual paths. Those are
completely implementation-dependent. That's how non-Unix systems can be
POSIX-conformat.
Relevant quote from Robert's mail:
It is actually messier that it first seems, if you have a builtin command,
it isn't simply finding that command's name in a PATH search that is
required, but that the directory (from PATH) in which it was found be the
one "associated" with the builtin command (how exactly that is determined,
or what it really even means is not specified anywhere). The effect is
that if a shell with a builtin "test" believes that the associated
directory is /bin and someone's path is /usr/bin:/bin - and there is a
test command in /usr/bin (even if /usr/bin and /bin are the same directory,
or /bin/name and /usr/bin/name are linked and so invoke the same thing)
then the filesystem command is supposed to be invoked rather than the
builtin. There are reasons for that, but they're really fairly stupid.
This is more complex than it needs to be (and should be).
For a user it is very hard to have any confidence in the posix-ness
of their scripts.
That's one reason this aspect of POSIX is widely ignored. It will be
easier to ignore it in the next version of the standard (not that it
wasn't before) because of the `intrinsics' concept.
--
``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/
- posix command search and execution, Mike Jonkmans, 2023/11/06
- Re: posix command search and execution, Chet Ramey, 2023/11/06
- Re: posix command search and execution, Mike Jonkmans, 2023/11/07
- Re: posix command search and execution, Robert Elz, 2023/11/09
- Re: posix command search and execution, Mike Jonkmans, 2023/11/09
- Re: posix command search and execution, Chet Ramey, 2023/11/10
- Re: posix command search and execution, Mike Jonkmans, 2023/11/11
- Re: posix command search and execution, Greg Wooledge, 2023/11/11
- Re: posix command search and execution, Mike Jonkmans, 2023/11/11
Re: posix command search and execution, Robert Elz, 2023/11/06