On Wednesday 10 April 2013 13:28:38 Paul Smith wrote:
> On Wed, 2013-04-10 at 18:18 +0200, Vincent de Phily wrote:
> > If the behaviour is expected (why ?), it would be usefull to explain the
> > difference between `command` and $(shell command) in the info pages.
> 
> There is no difference between `command` and $(shell command), except
> the order in which they're executed.
> 
> Remember that make will expand all make functions and variables in the
> recipe FIRST, then pass the resulting text string to the shell for the
> shell to execute.  Make doesn't interpret the results of the functions
> or variables itself.
> 
> (...)

Thanks, this makes sense.

Still an easy trap to fall into because Makefile syntax looks so much like 
shell that you quickly forget it isn't.

The info pages probably point out that double-evaluation gotcha somewhere 
(I'll check tomorrow), but it's the kind of detail that you easily miss 
because it sounds obvious so you'll skip the section. Sigh...


> In general you should never, and never need to, use $(shell ...) inside
> a recipe command.  You're already running a shell, so why?

Probably because I'm not a fan of the `` syntax: I prefer the shell's $() 
syntax which is more readable and can be nested. Make's $(shell) syntax seemed 
like a drop-in replacement.

-- 
Vincent de Phily

_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to