public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: tlaronde@polynum.com
To: Pedro Falcato <pedro.falcato@gmail.com>
Cc: devel@edk2.groups.io
Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1)
Date: Tue, 22 Nov 2022 09:14:08 +0100	[thread overview]
Message-ID: <Y3yE0PLPn2bQFLSE@polynum.com> (raw)
In-Reply-To: <CAKbZUD3rw0YNw7pq6a4rtSzjx9HOs0p2MnZ9tWypezaLvOnbKQ@mail.gmail.com>

Hello Pedro,

Le Mon, Nov 21, 2022 at 10:22:21PM +0000, Pedro Falcato a écrit :
> On Mon, Nov 21, 2022 at 9:21 PM <tlaronde@polynum.com> wrote:
> 
> > diff --git a/edksetup.sh b/edksetup.sh
> > index 06d2f041e6..46b295c430 100755
> > --- a/edksetup.sh
> > +++ b/edksetup.sh
> > @@ -105,6 +105,19 @@ function SetupEnv()
> >    fi
> >  }
> >
> > +# whereis(1) is not a POSIX utility and, for example, its implementation
> > +# in NetBSD is different form the Linux one.
> > +#
> > +function whereis()
> > +{
> > +  (
> > +    IFS=:
> > +    for dir in $PATH; do
> > +      eval ls $dir/${1}* 2>/dev/null || true
> > +    done
> > +  )
> > +}
> >
> Hi Thierry,
> 
> First of all, thanks for the patch! I had noticed this problem when running
> edksetup.sh on a POSIX but not quite Linux system before.
> 
> 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?

The problem is that which -a does not do what is required by the usage
of whereis(1) in the script and what is indeed implemented in Linux whereis(1) (and not in the obsolescent
NetBSD whereis(1)): look for "string*". "which -a python" or "which -a
'python*'" will return nothing.

This is why I ended up with this solution that uses only POSIX sh(1)
features and that is, if I'm not mistaken, an implementation of what is
used.

Best,
-- 
        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

  reply	other threads:[~2022-11-22  8:14 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 [this message]
2022-11-22 15:40   ` Rebecca Cran
2022-11-22 16:22     ` Pedro Falcato
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=Y3yE0PLPn2bQFLSE@polynum.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