I currently have this:

SHELL_CHECKED =                                                      \
  $(strip                                                            \
    $(if $(shell (($1) 1>/tmp/SC_so) || echo nonempty),              \
      $(error shell command '$1' failed.  Its stderr should be above \
              somewhere.  Its stdout is in '/tmp/SC_so'),            \
      $(shell cat /tmp/SC_so && rm -f /tmp/SC_so)))

Calls can safely be nested but not run in parallel.  I could use flock
(linux-only-ish) or mkdir trick (painful) or parallel --semaphore
(needs GNU parallel) but any of those would break nesting anyway.  I
guess a stack or something could be used but I'd like to avoid getting
that crazy.
Is there some way I'm missing?

It looks like checking $(.SHELLSTATUS) after might also involve a race?

It seems to me that a checked version of $(shell) would be a nice
feature to ship with Make since it's commonly wanted and  looks much
easier to implement inside make than outside it.

Britton

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to