[Top][All Lists]

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

Re: why does $$(shell bomb with a semicolon during SECONDEXPANSION?

From: Philip Guenther
Subject: Re: why does $$(shell bomb with a semicolon during SECONDEXPANSION?
Date: Mon, 12 Dec 2011 22:52:38 -0800

On Mon, Dec 12, 2011 at 10:26 PM, Mark Galeck (CW) <address@hidden> wrote:
> Why does this bomb:
> foobar: $$(shell echo prereq;)
>        touch $@
>>make foobar
> makefile:2: *** unterminated call to function `shell': missing `)'.  Stop.
> Without the ";" it is fine.  Why?  (I need the ; for the real, larger, file, 
> here it is just the SSCCE)

Because of the levels of parsing done by make.  When make parses that
line, it see a single variable expansion for the variable '$'.  So,
the semicolon is *not* eaten by variable expansion, but rather is seen
and parsed as the semicolon that (optionally) separates prerequisites
from the first command in the rule, ala:

target : prereq ; command

It doesn't know that you mean for the semicolon to be eaten by
variable second-expansion, so it treats everything between the colon
and the semicolon as the prerequisites, which are expanded again
later, and everything after the semicolon as the first command in the

The solution is to hide the semicolon from the first round of make
expansion, ala:

foobar: $$(shell echo prereq$${semi})
       touch $@

Philip Guenther

reply via email to

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