grub-mkconfig: Use portable "command -v" to detect installed programs

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: ash, bash, busybox,
dash, ksh, mksh and 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.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Eli Schwartz authored and Daniel Kiper committed 2019-10-28 15:38:48 +01:00
1 parent b78d570a36
commit 28a7e597de
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ if test "x$grub_mkrelpath" = x; then
grub_mkrelpath="${bindir}/@grub_mkrelpath@"
fi
if which gettext >/dev/null 2>/dev/null; then
if command -v gettext >/dev/null; then
:
else
gettext () {