commit:     ad73851922df05d91b9be52f41529014c3482113
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 19 16:01:18 2019 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Mar 19 16:57:54 2019 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=ad738519

Makefile: remove BASH-specific "type -p" and "&>" idioms.

The Makefile uses two "type -p" commands to determine if the "convert"
and "xsltproc" commands are present. The "type" command itself is
defined in POSIX,

  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html

but the additional "-p" flag is BASH-specific. This can lead to
unexpected behavior when the /bin/sh symlink that the Makefile uses by
default points to a non-BASH shell:

  $ dash
  $ type -p convert
  -p: not found
  convert is /usr/bin/convert

By chance, this is ultimately not fatal, but does cause the default
target to output some confusing messages. And in fact the output from
the "type -p" command is never used, which means that "type" itself
should suffice, in any shell. Thus this commit drops the two "-p"
arguments to "type".

The same two "type" commands attempt to redirect both stdout and
stderr to /dev/null using the BASH "&>" shortcut. This commit replaces
it with the standard, but more verbose incantation ">/dev/null 2>&1"
that is portable to other shells.

Closes: https://bugs.gentoo.org/680932
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
Signed-off-by: Brian Evans <grknight <AT> gentoo.org>

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d4182a8..a61128b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,8 @@ image_files := $(shell find -name "*.svg" | sed -e 
"s/svg$$/png/")
 all: prereq $(text_files) $(image_files)
 
 prereq:
-       @type -p convert &>/dev/null || { echo "media-gfx/imagemagick with 
corefonts, svg and truetype required" >&2; exit 1; }; \
-               type -p xsltproc &>/dev/null || { echo "dev-libs/libxslt is 
required" >&2; exit 1; }
+       @type convert >/dev/null 2>&1 || { echo "media-gfx/imagemagick with 
corefonts, svg and truetype required" >&2; exit 1; }; \
+               type xsltproc >/dev/null 2>&1 || { echo "dev-libs/libxslt is 
required" >&2; exit 1; }
 
 %.png : %.svg
        convert $< $@

Reply via email to