tech-userlevel archive

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

Re: sh(1): POSIX "Command Search and Execution"



On Sun, Sep 22, 2024 at 05:35:39PM +0000, David Holland wrote:
> On Sun, Sep 22, 2024 at 09:09:06AM +0200, tlaronde%kergis.com@localhost wrote:
>  > [stuff about searching $PATH for more things]
> 
> A different and much less invasive way to get the first 90% of this is
> to pick an otherwise unused metacharacter (e.g. @) and use it as a tag
> meaning "search for the rest of this on $PATH", the same way ~ is a
> tag that means "find this name by starting in $HOME".
> 
> Then you just write @foo/ls or @bar/ls. You could also extend it to
> work on arguments as well as command names, though you'd probably want
> it to use a different search path variable.

But in my mind, the feature is to be used also, in interactive (so
user will have constantly to remind to add the prefix to a qualified
command). Plus one would have to treat '@' in a special way, probably
fully qualifying first the pathname, and this will duplicate code.

'%' is already reserved---if not documented---for a prefix directive
in PATH (...:"%func:/some/dir:...)---so it's specialized: just in
PATH, but...---, better not "waste" another char for a special thing.

I will see when writing the patch, but I think the straightforward
approach is more ergonomic, less invasive, and will add (in the not
SMALL case) very few bytes to the executable---I will write things so
that in the SMALL case the option is not implemented and that this
changes nothing to the size of the resulting binary.

-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index