From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mx.groups.io with SMTP id smtpd.web10.23944.1669134686607972303 for ; Tue, 22 Nov 2022 08:31:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VNkT0+ZE; spf=pass (domain: gmail.com, ip: 209.85.215.171, mailfrom: pedro.falcato@gmail.com) Received: by mail-pg1-f171.google.com with SMTP id q71so14490828pgq.8 for ; Tue, 22 Nov 2022 08:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=l1f7rew9hwpWp3ZbMdeLx9W2VaO6oaZSOm0XwY4JeRk=; b=VNkT0+ZEuQcTLWZmW4rgguy6p9EYzSe8oMiAXS7mBI89Wdet1+7gphGimtOvu7oIiu FgqXEHl6ayF6FbYw+BbfF/f3AtWZFJQpn7rNDzxj2LNMp7ouRbb8IXa7sYSgYxfznfqn 6CY1WPB13RrQtm4YiYv/oWDyBDXnZOp0wiwy6v6RkFIpT9dYVT51TV7j8y/N3L4qhCWH taSdVbXKTTx9D6Ae5e3B9jbjTWkrBEkcZGEFMxvMYALwQBGumXANclJ6rVzsJLkorQRf ulXoEoVwXfgl0FZzRy0WD4/M5dYLYzPdc+C/v3BPqbmJtYTnNFN87gpP4oPsAEb54dUx 8YQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l1f7rew9hwpWp3ZbMdeLx9W2VaO6oaZSOm0XwY4JeRk=; b=ceDy6GR/h3D9vmROrN3zBr0PiagK3KEKZNYZh/Uz742HQuvt0V7j/Byc4bTC7u2edB d8G8ixVwwph4+3JuW3AL/0R1DesPosSqMlbuZJN/AEfL3yMlkukyBaLjG5C3sN1zQuwG ha8f8MiUXDbpdmk3REXqwWVDCTbVK9hzJkZfTn9jKv6PymR8GRHuy2r6L09iUthf8o6J 0Fz63h6F8iS3iuFDvt0sYqHI+9Uxr0h6GzNZjs7LZv7zADstzCa3XBWZTIxgzk1sb90n huqRFQAa+qqVYCHNNWA/Y2drR1NoQQG760JFBuUDtfGm5ydN5wOxnW8fJfgJLUWN9Zel +GAw== X-Gm-Message-State: ANoB5pnZsU+Y/3/CW0T9N8H5IE7YxbqAvLD5jfeRdv/ehJR2G9hs+gij Z5uBEACJ798Uop/Pq/quwRfgb1OAOUjMcG/Ch18= X-Google-Smtp-Source: AA0mqf5D4cwSgZIYqrtqACcMW4LiqpJwQx4k5DBA2hwpVYQA2yiu9cI1Yjj8ksn0hFkeDqRk7kgrrILqNqDGY1pfMyM= X-Received: by 2002:a63:4944:0:b0:44e:466f:4759 with SMTP id y4-20020a634944000000b0044e466f4759mr4351512pgk.194.1669134686068; Tue, 22 Nov 2022 08:31:26 -0800 (PST) MIME-Version: 1.0 References: <0bb285e2-ca66-f78a-7da9-ffd13473b61a@quicinc.com> In-Reply-To: From: "Pedro Falcato" Date: Tue, 22 Nov 2022 16:31:14 +0000 Message-ID: Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1) To: tlaronde@polynum.com Cc: Rebecca Cran , devel@edk2.groups.io Content-Type: multipart/alternative; boundary="0000000000000ba5b805ee11b4aa" --0000000000000ba5b805ee11b4aa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 22, 2022 at 4:26 PM wrote: > Le Tue, Nov 22, 2022 at 08:40:30AM -0700, Rebecca Cran a =C3=A9crit : > > 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 whi= ch > > > 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. > Sorry, what? This sounds so broken. How can a script shebang ever work? For Sane(tm) systems, I propose command -v python3 + $(command -v python3) -c 'import sys; print(sys.version.split(" ")[0])', which gives us the path to the Python 3 interpreter + the path in a relatively easy, simple way. I think this could work mostly everywhere but apparently NetBSD since you don't provide python3? Which makes little sense in my head. Pedro --0000000000000ba5b805ee11b4aa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Nov 22, 2022 at 4:26 PM <tlaronde@polynum.com> wrote:
Le Tue, Nov 22, 2022 at 08:40:30AM -0700, Rebecca Cran a =C3=A9crit : > On 11/21/22 15:22, Pedro Falcato wrote:
>
> > I kind of dislike your solution. Does NetBSD ship /bin/which by d= efault?
> > I think replacing whereis with "which -a" would be a lo= t better.
> > I don't think there's a 100% standard way to do this in P= OSIX, 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/96999197= 99/
>
> 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"?<= br>
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 th= e
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.

Sorry, what? This sounds so broken. How can a s= cript shebang ever work?

For Sane(tm) systems, I p= ropose command -v python3=C2=A0+ $(command -v python3) -c 'import sys; = print(sys.version.split(" ")[0])',
which gives us t= he path to the Python 3 interpreter + the path in a relatively easy, simple= way.
I think this could work mostly everywhere but apparently Ne= tBSD since you don't provide python3? Which makes little sense in my he= ad.

Pedro
--0000000000000ba5b805ee11b4aa--