star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit b1684147c8bcf74e29567b208ce7b33a7efbe767
parent f68771cf9dbd742e6a005a3dc4d35b62f6b14a99
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri,  6 Sep 2024 12:42:03 +0200

Correction of the showvar function

With some versions of GNU make, the function could fail when make was
run in parallel; the file descriptor used to display the value of a
Makefile macro was already reserved by GNU make to synchronise its
tasks. This is now avoided by executing the make command in the showvar
function, without any options, i.e. without using the jobserver, and
therefore without file descriptor conflicts. This is not a problem
because the Makefile created ‘on the fly’ is only there to print the
value of a macro defined in the config.mk file, and therefore does not
need to be run in parallel. Quite the contrary.

This commit also removes a shellcheck warning that the MAKE environment
variable could be used without being defined: if it is not defined, the
make command is used by default.

Diffstat:
Msrc/build.sh | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/build.sh b/src/build.sh @@ -75,9 +75,15 @@ showvar() { # To avoid messages from Make being displayed instead of the value of # the queried variable, we redirect its output to /dev/null and open a - # new file descriptor to stdout to print the variable - # shellcheck disable=SC2154 # MAKE is referenced but not assigned -<< EOF ${MAKE} -f 3>&1 1>/dev/null 2>&1 - || kill -HUP $$ + # new file descriptor to stdout to print the variable. + # + # The MAKEFLAGS environment variable is cleared to prevent make + # defining options which reserve the file descriptor used to print the + # variable, which would result in a ‘wrong file descriptor’ error. + # This can be the case with certain versions of GNU make which, when + # run in parallel, use pipe file descriptors to synchronise with the + # jobserver. +<< EOF MAKEFLAGS="" ${MAKE:-make} -f 3>&1 1>/dev/null 2>&1 - || kill -HUP $$ .POSIX: include config.mk showvar: