From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.200]) by mx.groups.io with SMTP id smtpd.web10.23791.1669134381388640104 for ; Tue, 22 Nov 2022 08:26:22 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@polynum.com header.s=202006 header.b=X1VsBjIf; spf=pass (domain: sfr.fr, ip: 93.17.128.200, mailfrom: thierry.laronde@sfr.fr) X-mail-filterd: {"version":"1.5.3","queueID":"4NGqQ33qYpz1LQMFB","contextId": "58066d03-d9d0-4cc8-887b-c6795dcca20a"} Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) by msfrf2618.sfr.fr (SMTP Server) with ESMTP id 4NGqQ33qYpz1LQMFB; Tue, 22 Nov 2022 17:26:19 +0100 (CET) X-mail-filterd: {"version":"1.5.3","queueID":"4NGqQ31vlPz1LQMF4","contextId": "88b23932-c235-48e7-85b2-7b2bf18fef85"} 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=1669134379; h=Date:From:To:Cc:Subject:References:In-Reply-To; bh=GOnN/CG01Q OsRiQuoQ/U0rjqNWxq9nw+T/EzZw2sExY=; b=X1VsBjIfVpoH+i9U+/vee9Hy3J4kcmt0NoWH1j g0v7BAbs68uVJ6XDANMVmv8o4bX0aBfNq6A3D+4aiMWnKskdQXESB7c8typV1Nll1LTiMbOAXLH/ eLCM8ZT41FQinPzjM7gT7y2AkcgCKCWs2QPONFqGaYpXLxIzYWWi/k1dDb0Xn3yWWjo4T5mIo2aO n9t8ibyv67rWqMHXwRnroQDAC5gPybtlld7aP9O2oYBcWmTV9VpWE8PAs/NRmeNDe3cOYPvbgsLm Yc79xGBbhmdxfLL3H8OykXFAgQkTIA8jKlWen+CEn1GmV9JNpZ7AJbhdQZQBZ/1KzfekqnAUZDGQ == 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 msfrf2618.sfr.fr (SMTP Server) with ESMTPSA id 4NGqQ31vlPz1LQMF4; Tue, 22 Nov 2022 17:26:19 +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 2AMGQGOk001750; Tue, 22 Nov 2022 17:26:16 +0100 (CET) Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 2AMGQGtX001950; Tue, 22 Nov 2022 17:26:16 +0100 (CET) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Tue, 22 Nov 2022 17:26:16 +0100 From: tlaronde@polynum.com To: Rebecca Cran Cc: devel@edk2.groups.io, pedro.falcato@gmail.com Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1) Message-ID: References: <0bb285e2-ca66-f78a-7da9-ffd13473b61a@quicinc.com> MIME-Version: 1.0 In-Reply-To: <0bb285e2-ca66-f78a-7da9-ffd13473b61a@quicinc.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Le Tue, Nov 22, 2022 at 08:40:30AM -0700, Rebecca Cran a =E9crit : > On 11/21/22 15:22, Pedro Falcato wrote: >=20 > > I kind of dislike your solution. Does NetBSD ship /bin/which by defau= lt? > > 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? >=20 >=20 > "command" seems to be the POSIX way to do this? > https://pubs.opengroup.org/onlinepubs/9699919799/ >=20 > Though "whereis python3" shows the following on my system: >=20 > 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 >=20 > "which -a python3" returns: >=20 > /usr/bin/python3 > /bin/python3 >=20 > And "command -p -v" returns: >=20 > /bin/python3 >=20 > 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. --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C