From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.196]) by mx.groups.io with SMTP id smtpd.web11.13980.1669104852149971152 for ; Tue, 22 Nov 2022 00:14:12 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@polynum.com header.s=202006 header.b=kKe3L6d/; spf=pass (domain: sfr.fr, ip: 93.17.128.196, mailfrom: thierry.laronde@sfr.fr) X-mail-filterd: {"version":"1.5.3","queueID":"4NGcV96JT3z1LQLnw","contextId": "229cf860-c2eb-4c5f-aab7-795158e63a52"} Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) by msfrf2612.sfr.fr (SMTP Server) with ESMTP id 4NGcV96JT3z1LQLnw; Tue, 22 Nov 2022 09:14:09 +0100 (CET) X-mail-filterd: {"version":"1.5.3","queueID":"4NGcV94NFcz1LQLp1","contextId": "6eef6615-2ffc-4aec-81db-b394344a805c"} X-sfr-mailing: LEGIT X-sfr-spamrating: 36 X-sfr-spam: not-spam DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=polynum.com; s=202006; t=1669104849; h=Date:From:To:Cc:Subject:References:In-Reply-To; bh=JJQgJrIbzP /b583SNXKR/a10PGbtSOdyDZEufx3e09Y=; b=kKe3L6d/sO8TG6VMcQ2DZx8zEYXoB6bI1r77BW gr0h+KTCzzWMUeMIf1c+NVaBRP2tckoaAbxAdd+Pe2kZ9EGXCefaU0rYXuQxtOjgS/V2dIPCBYEo poZigKRVLf0dzonMYalZ+Aj55IZuIJ7ealSgMl0EUJIafDPl/C4Qv/qsucQ4fQMGPLaoQG4FICNQ jWAJdYS79V98SqSrOB731Xw+C0emqIsfqhRxVTacSIn5ewEFUL1lct9Y+LcI82/0LaIfOHZr4to5 9PyMlUZSfWlTwTrTqYlTz1blWjIVuUHqyNvof9XQZPdHiTXySvOM1OvyEIoLUpr/K3Q51TGt8+qQ == Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: thierry.laronde@sfr.fr) by msfrf2612.sfr.fr (SMTP Server) with ESMTPSA id 4NGcV94NFcz1LQLp1; Tue, 22 Nov 2022 09:14:09 +0100 (CET) Authentication-Results: sfr.fr; auth=pass (LOGIN) smtp.auth=thierry.laronde@sfr.fr Received: from cauchy.polynum.local (localhost [127.0.0.1]) by cauchy.polynum.local (8.15.2/8.15.2) with ESMTP id 2AM8E8lt000689; Tue, 22 Nov 2022 09:14:08 +0100 (CET) Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 2AM8E89g000194; Tue, 22 Nov 2022 09:14:08 +0100 (CET) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Tue, 22 Nov 2022 09:14:08 +0100 From: tlaronde@polynum.com To: Pedro Falcato Cc: devel@edk2.groups.io Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1) Message-ID: References: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Pedro, Le Mon, Nov 21, 2022 at 10:22:21PM +0000, Pedro Falcato a =E9crit : > On Mon, Nov 21, 2022 at 9:21 PM wrote: >=20 > > 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 implementa= tion > > +# in NetBSD is different form the Linux one. > > +# > > +function whereis() > > +{ > > + ( > > + IFS=3D: > > + for dir in $PATH; do > > + eval ls $dir/${1}* 2>/dev/null || true > > + done > > + ) > > +} > > > Hi Thierry, >=20 > First of all, thanks for the patch! I had noticed this problem when run= ning > edksetup.sh on a POSIX but not quite Linux system before. >=20 > 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 where= is(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, --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C