[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to implement safe version of $(shell) without .NOTPARALLEL ?
From: |
Britton Kerin |
Subject: |
how to implement safe version of $(shell) without .NOTPARALLEL ? |
Date: |
Sun, 17 Mar 2019 05:57:45 -0800 |
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
- how to implement safe version of $(shell) without .NOTPARALLEL ?,
Britton Kerin <=