posix command search and execution

2023-11-06 Thread Mike Jonkmans
Hi, I have some remarks/questions on POSIX Command Search and Execution, related to bash and some to POSIX itself. Introduction https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 describes what to do when a simple command name needs to be resolved. A

Re: posix command search and execution

2023-11-06 Thread Chet Ramey
On 11/6/23 10:48 AM, Mike Jonkmans wrote: POSIX Command Search According to these docs (what I make of it), resolving is done in steps, the first applicable step is used: 1) No slash in the name. 1a) Run the builtin if the name matches that of a Special Builtin. 1b) List several names that h

Re: posix command search and execution

2023-11-06 Thread Robert Elz
Date:Mon, 6 Nov 2023 14:28:24 -0500 From:Chet Ramey Message-ID: <0ab6075e-22bf-43cd-992c-b2476f626...@case.edu> | On 11/6/23 10:48 AM, Mike Jonkmans wrote: | > According to these docs (what I make of it), resolving is done | > in steps, the first applicable step

Re: posix command search and execution

2023-11-07 Thread Mike Jonkmans
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

Re: posix command search and execution

2023-11-07 Thread Chet Ramey
On 11/6/23 9:39 PM, Robert Elz wrote: | > 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 th

Re: posix command search and execution

2023-11-07 Thread Chet Ramey
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 chec

Re: posix command search and execution

2023-11-07 Thread Mike Jonkmans
On Tue, Nov 07, 2023 at 09:39:33AM +0700, Robert Elz wrote: > Date:Mon, 6 Nov 2023 14:28:24 -0500 > From:Chet Ramey > Message-ID: <0ab6075e-22bf-43cd-992c-b2476f626...@case.edu> > > | On 11/6/23 10:48 AM, Mike Jonkmans wrote: > | > According to these docs (what I

Re: posix command search and execution

2023-11-07 Thread Mike Jonkmans
On Tue, Nov 07, 2023 at 11:49:25AM -0500, Chet Ramey wrote: > On 11/7/23 8:54 AM, Mike Jonkmans wrote: ... > > > 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; the

Re: posix command search and execution

2023-11-08 Thread Chet Ramey
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

Re: posix command search and execution

2023-11-08 Thread Chet Ramey
On 11/7/23 5:37 PM, Mike Jonkmans wrote: On Tue, Nov 07, 2023 at 11:49:25AM -0500, Chet Ramey wrote: On 11/7/23 8:54 AM, Mike Jonkmans wrote: ... 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

Re: posix command search and execution

2023-11-08 Thread Robert Elz
Date:Tue, 7 Nov 2023 23:04:10 +0100 From:Mike Jonkmans Message-ID: <20231107220410.gc27...@jonkmans.nl> | In particular, a user function with the name of a standard utility, | will be called at this point. Yes. That much is very clear. | Chet mentioned that

Re: posix command search and execution

2023-11-08 Thread Mike Jonkmans
On Wed, Nov 08, 2023 at 10:38:19AM -0500, Chet Ramey wrote: > On 11/7/23 5:04 PM, Mike Jonkmans wrote: > > 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 sma

Re: posix command search and execution

2023-11-08 Thread Mike Jonkmans
On Wed, Nov 08, 2023 at 11:52:19PM +0700, Robert Elz wrote: > Date:Tue, 7 Nov 2023 23:04:10 +0100 > From:Mike Jonkmans > Message-ID: <20231107220410.gc27...@jonkmans.nl> > > | It makes sense to partition the builtins in three categories with > | a separate name fo

Re: posix command search and execution

2023-11-09 Thread Mike Jonkmans
On Wed, Nov 08, 2023 at 10:42:20AM -0500, Chet Ramey wrote: > On 11/7/23 5:37 PM, Mike Jonkmans wrote: > > On Tue, Nov 07, 2023 at 11:49:25AM -0500, Chet Ramey wrote: > > > On 11/7/23 8:54 AM, Mike Jonkmans wrote: > > So the discussion is hidden. Hmm. > Not hidden; if you look at the open group's m

Re: posix command search and execution

2023-11-09 Thread Robert Elz
Date:Thu, 9 Nov 2023 14:21:35 +0100 From:Mike Jonkmans Message-ID: <20231109132135.ga208...@jonkmans.nl> | If I am not mistaken, for POSIX compliance, both /bin and /usr/bin have | to be in PATH (see quote from Robert). No, I didn't say that, there are no partic

Re: posix command search and execution

2023-11-09 Thread Mike Jonkmans
On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert Elz wrote: > Date:Thu, 9 Nov 2023 14:21:35 +0100 > From:Mike Jonkmans > Message-ID: <20231109132135.ga208...@jonkmans.nl> > > | If I am not mistaken, for POSIX compliance, both /bin and /usr/bin have > | to be in PA

Re: posix command search and execution

2023-11-10 Thread Chet Ramey
On 11/8/23 5:10 PM, Mike Jonkmans wrote: 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. That was indeed what I meant. Does the new POSIX version w

Re: posix command search and execution

2023-11-10 Thread Chet Ramey
On 11/8/23 6:40 PM, Mike Jonkmans wrote: On Wed, Nov 08, 2023 at 11:52:19PM +0700, Robert Elz wrote: Date:Tue, 7 Nov 2023 23:04:10 +0100 From:Mike Jonkmans Message-ID: <20231107220410.gc27...@jonkmans.nl> | It makes sense to partition the builtins in three ca

Re: posix command search and execution

2023-11-10 Thread Chet Ramey
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 u

Re: posix command search and execution

2023-11-10 Thread Chet Ramey
On 11/9/23 11:17 AM, Mike Jonkmans wrote: On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert Elz wrote: Date:Thu, 9 Nov 2023 14:21:35 +0100 From:Mike Jonkmans Message-ID: <20231109132135.ga208...@jonkmans.nl> | If I am not mistaken, for POSIX compliance, both /

Re: posix command search and execution

2023-11-11 Thread Mike Jonkmans
On Fri, Nov 10, 2023 at 08:07:31PM -0500, Chet Ramey wrote: > On 11/9/23 11:17 AM, Mike Jonkmans wrote: > > On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert Elz wrote: > > > > On Ubuntu 22.04 `getconf path' returns /bin:/usr/bin > > and these are symlinked. > Then that's an issue to take up with D

Re: posix command search and execution

2023-11-11 Thread Greg Wooledge
On Sat, Nov 11, 2023 at 09:14:41AM +0100, Mike Jonkmans wrote: > On Fri, Nov 10, 2023 at 08:07:31PM -0500, Chet Ramey wrote: > > On 11/9/23 11:17 AM, Mike Jonkmans wrote: > > > On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert Elz wrote: > > > > > > On Ubuntu 22.04 `getconf path' returns /bin:/usr/

Re: posix command search and execution

2023-11-11 Thread Mike Jonkmans
On Sat, Nov 11, 2023 at 08:31:14AM -0500, Greg Wooledge wrote: > On Sat, Nov 11, 2023 at 09:14:41AM +0100, Mike Jonkmans wrote: > > On Fri, Nov 10, 2023 at 08:07:31PM -0500, Chet Ramey wrote: > > > On 11/9/23 11:17 AM, Mike Jonkmans wrote: > > > > On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert El