Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iKw4W-0000dU-Mr for mharc-grub-devel@gnu.org; Wed, 16 Oct 2019 23:03:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34103) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKw4T-0000dE-Sr for grub-devel@gnu.org; Wed, 16 Oct 2019 23:03:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKw4S-0003kV-DQ for grub-devel@gnu.org; Wed, 16 Oct 2019 23:03:25 -0400 Received: from orion.archlinux.org ([88.198.91.70]:50680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKw4R-0003jz-UF for grub-devel@gnu.org; Wed, 16 Oct 2019 23:03:24 -0400 Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 8932815DFDBDDE; Thu, 17 Oct 2019 03:03:19 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id 009EE15DFDBDDD; Thu, 17 Oct 2019 03:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1571281399; bh=DCp05zLOPE1aCBAUCFmBzpslSYru0egaUw3yWi54Bc4=; h=From:To:Subject:Date; b=SbLaiBaL4miD61A/553J+7vuyl/J7RNUT5aaNV/IEe9yQaTSDjETPC0SouqVV20tB ZfeZ7fs6dVYp1Qjulc9oSjx3FjxtgmTsIySOaLgPg3tb3uoJ2tOV7gduaQFWL8CWEQ n4ZYTD7eIF0MbGrLeFnziPnd9AGljldIrX0nPsA9VQ06g4wDR88FniQUM1TeYMmGXU ypq5K+QZzz2wkEXMIj3muHBVUn0xiGDfjKc1lCykgYTV6TkcTgLHQ+2GuXNRMhoq1y ckiB079a7+SvfAr9y/6XOVbAhxBlbXoe9VY579xeMWu9SppSugiqvu4aACfXbXi9vn 3voMvcgZSgaZjUiBJR9ARmaSlWY6Q7+Wih3N0Y3OChX2bTwGKsx7LRs0ccaLXqcmVY 8h3dJgfeNw+Ar7l+WMLEX8zJaAnHVWo8qCUT2Jw862fBgEDUksFgU9oDS58PuRTSQ/ pfYAL4ExJkhASt+s5G+5tfHJJlYrzgjJuN9hIcf9Ib8KX/oPe3+5x33miSSbQk4H+4 o48xJOEFrbWGTJhCgfzjoTGI6UADFhHlWSADUgitQYBDX+JZXyZgz992hYgNB6QKBa Zk6pfwIyhPMoNP03LZEccHCM/tOWGpl4/6XR3pJqEKAWxW6p03EPx6UuYccPV4WZtH 4iGQn3IuuXJ9RhsZb8aNpSas= From: Eli Schwartz To: grub-devel@gnu.org Subject: [PATCH] grub-mkconfig: use portable 'command -v' to detect installed programs Date: Wed, 16 Oct 2019 23:03:06 -0400 Message-Id: <20191017030306.369509-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 88.198.91.70 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Oct 2019 03:03:27 -0000 The 'which' utility is not guaranteed to be installed either, and if it is, its behavior is not portable either. Conversely, the 'command -v' shell builtin is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere. Examples of open-source shells likely to be installed as /bin/sh on linux, which implement the 11-year-old standard: bash, dash, busybox ash, ksh, mksh, zsh A side benefit of using the POSIX portable option is that it requires neither an external disk executable, nor (because unlike 'which', the exit code is reliable) a subshell fork. This therefore represents a mild speedup. --- util/grub-mkconfig_lib.in | 2 +- util/grub.d/30_os-prober.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 0f801cab3..50f2908d2 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -34,7 +34,7 @@ if test "x$grub_mkrelpath" =3D x; then grub_mkrelpath=3D"${bindir}/@grub_mkrelpath@" fi =20 -if which gettext >/dev/null 2>/dev/null; then +if command -v gettext >/dev/null; then : else gettext () { diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 515a68c7a..ed3171417 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -30,7 +30,7 @@ if [ "x${GRUB_DISABLE_OS_PROBER}" =3D "xtrue" ]; then exit 0 fi =20 -if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-pr= ober 2> /dev/null`" ] ; then +if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober = > /dev/null ; then # missing os-prober and/or linux-boot-prober exit 0 fi --=20 2.23.0