public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: Rebecca Cran <quic_rcran@quicinc.com>
Cc: devel@edk2.groups.io, tlaronde@polynum.com
Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1)
Date: Tue, 22 Nov 2022 16:22:20 +0000	[thread overview]
Message-ID: <CAKbZUD0EQQX1bgkeF3h9=5_vjqZPv+9tQb4uE_him0ykpV+v_w@mail.gmail.com> (raw)
In-Reply-To: <0bb285e2-ca66-f78a-7da9-ffd13473b61a@quicinc.com>

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

On Tue, Nov 22, 2022 at 3:40 PM Rebecca Cran <quic_rcran@quicinc.com> wrote:

> 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"?
>
> --
> Rebecca Cran
>

I guess we could just use /bin/python3 (as in command -v python3) and
readlink to find the actual version?

In my local system "command -v python3" returns /usr/bin/python3
"readlink /usr/bin/python3" returns python3.10, which we could promptly
parse into a version?

I don't know how portable this is, but it's an idea. I definitely don't see
the reason to iterate through every possible python3* in PATH.

Pedro

[-- Attachment #2: Type: text/html, Size: 2180 bytes --]

  reply	other threads:[~2022-11-22 16:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 13:09 edksetup.sh: fix for non POSIX whereis(1) tlaronde
2022-11-21 22:22 ` [edk2-devel] " Pedro Falcato
2022-11-22  8:14   ` tlaronde
2022-11-22 15:40   ` Rebecca Cran
2022-11-22 16:22     ` Pedro Falcato [this message]
2022-11-22 16:26     ` tlaronde
2022-11-22 16:31       ` Pedro Falcato
2022-11-22 17:07         ` tlaronde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKbZUD0EQQX1bgkeF3h9=5_vjqZPv+9tQb4uE_him0ykpV+v_w@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox