On Mon, 2024-01-22 at 21:33 -0500, Dmitry Goncharov wrote:
> On Mon, Jan 22, 2024 at 8:16 AM Paul Smith <psm...@gnu.org> wrote:
> > I don't understand the point you are making about +!=.
> 
> If all new operators behave the same as +=, when the variable exists,
> then +!= is not needed, because +!= would do the same as +=$(shell
> ...).

They are not equivalent since if the variable is recursive the +!=
model would execute the shell script immediately, one time, and append
the result, while += $(shell ...) would re-run the shell script every
time the variable was expanded.

In addition to efficiency, it could be a noticeable behavior if the
shell script does something (like list files or obtain a date or
something) which might change between invocations.

In other words in this situation:

  foo = bar
  foo +!= echo baz

then the value of foo would be "bar baz", while in this situation:

  foo = bar
  foo += $(shell echo baz)

the value of foo would be "bar $(shell echo baz)".  Of course you can
rewrite it to be the equivalent, like this:

  foo = bar
  __foo := $(shell echo baz)
  foo += $(__foo)

here bar has a value of "bar $(__foo)": as long as __foo was not reset
then it would give the same result as +!=.

-- 
Paul D. Smith <psm...@gnu.org>            Find some GNU Make tips at:
https://www.gnu.org                       http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist


Reply via email to