help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a $(shell ...) function that dies on error


From: Britton Kerin
Subject: a $(shell ...) function that dies on error
Date: Wed, 5 Nov 2014 09:45:20 -0900

I wonder if it would be good to have a built-in like $(shell ...) that dies
if the given command exits with non-zero exit code.

Currently I have this somewhat icky fctn:

# This function works almost exactly like the builtin shell command, except it
# stops everything with an error if the shell command given as its argument
# returns non-zero when executed.  The other difference is that the output
# is passed through the strip make function (the shell function strips
# only the last trailing newline).  In practice this doesn't matter much
# since the output is usually collapsed by the surroundeing make context
# to the same result produced by strip.  WARNING: don't try to nest calls
# to this function.
SHELL_CHECKED = \
  $(strip \
    $(if $(shell (($1) 1>/tmp/SC_so) || echo 'non-empty'), \
      $(error shell command '$1' failed.  Its stderr should be above \
              somewhere.  Its stdout is available for review in '/tmp/SC_so'), \
      $(shell cat /tmp/SC_so)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]