bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behaviour of $(shell command args) is dangerously different from `co


From: Vincent de Phily
Subject: Re: Behaviour of $(shell command args) is dangerously different from `command args`
Date: Wed, 10 Apr 2013 19:56:16 +0200
User-agent: KMail/4.10.2 (Linux/3.7.9-hardened; KDE/4.10.2; x86_64; ; )

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]