[edk2-devel] edksetup.sh: fix for non POSIX whereis(1)

tlaronde at polynum.com tlaronde at polynum.com
Tue Nov 22 16:26:16 UTC 2022


Le Tue, Nov 22, 2022 at 08:40:30AM -0700, Rebecca Cran a écrit :
> On 11/21/22 15:22, Pedro Falcato wrote:
> 
> > I kind of dislike your solution. Does NetBSD ship /bin/which by default?
> > I think replacing whereis with "which -a" would be a lot better.
> > I don't think there's a 100% standard way to do this in POSIX, as which
> > isn't POSIX either, and your solution seems... hacky?
> 
> 
> "command" seems to be the POSIX way to do this?
> https://pubs.opengroup.org/onlinepubs/9699919799/
> 
> Though "whereis python3" shows the following on my system:
> 
> python3: /usr/bin/python3.9-config /usr/bin/python3.9 /usr/bin/python3
> /usr/lib/python3.9 /usr/lib/python3 /etc/python3.9 /etc/python3
> /usr/local/lib/python3.9 /usr/include/python3.9 /usr/share/python3
> /usr/share/man/man1/python3.1.gz
> 
> "which -a python3" returns:
> 
> /usr/bin/python3
> /bin/python3
> 
> And "command -p -v" returns:
> 
> /bin/python3
> 
> I don't know if we need all the results from "whereis"?

The problem is when one does not know which exact version of python
is here and how, exactly, the command is named.

whereis(1) returns whatever command with python3 as prefix, while
command or "which -a" will return only exactly python3. If, on the
system, python is fully version qualified (as is the case with
pkgsrc, the opt packages framework, used on NetBSD):

which -a python3

will return nothing, since, it is python3.9 for example on the OS.


There is a way to manipulate the namespace, since edk2setup.sh sets
environment and looks, by default, in some directories, but I have
respected the logics here: since whereis(1) is used to find a python3
related command in the PATH, even if it is named python3.x, the simplest
is to provide a basic whereis implementation in the script itself. Or,
changing the behavior, will perhaps break existing installation handling
the builds.
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96572): https://edk2.groups.io/g/devel/message/96572
Mute This Topic: https://groups.io/mt/95182516/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list