On Sat, 2020-04-18 at 21:17 +0200, R. Diez wrote:
> > I don't see why not.  Do you think there is some reason it wouldn't
> > be possible?
> 
> Hahaha. I was obviously trying to get you to write it. Well, maybe
> just the code, I can write the comments myself... O8-)

Oh.  Well, you should just ask :)

You need to escape all the "$" other than the ones you want to be
evaluated by the call (e.g., the arguments to the call).

Something like:

  Deferred = $1 = $$(eval $1 := $$$$(shell $2))$$($1)

Then:

  $(eval $(call Deferred,OUTPUT,some-command))

Defines OUTPUT as a deferred variable assigned to running some-command
in $(shell ...)

There are issues with this.  If the command you want to run has
unmatched ")" you have problems.  Also if you want use a literal '$' in
some-command you'll have problems getting enough escaping although it
can be done.

But for simple commands it should work.

Personally I'm not convinced the eval/call version is more readable but
YMMV.


Reply via email to