help-make
[Top][All Lists]
Advanced

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

Re: escaping bracket in function arguments


From: Garrett Cooper
Subject: Re: escaping bracket in function arguments
Date: Tue, 23 Dec 2008 12:51:38 -0800

On Dec 23, 2008, at 6:04, Mayuresh <address@hidden> wrote:

On 12/22/08, Mayuresh <address@hidden> wrote:
I am not able to find the right way to escape bracket in particular in
the arguments of a function. See example below:

LIST=a b c
LISTP=$(addprefix "\(", $(LIST))

all:
    echo $(LISTP)

I get the error:
makefile:2: *** unterminated call to function `addprefix': missing `)'.
Stop.

I can work around this by defining bracket as a variable and then using
it in
place of actual bracket, though it will be nicer if I could escape the
bracket directly. Can someone help?

Mayuresh.

Saying something along the lines of ...

PAREN :=(
LIST :=a b c
LISTP := $(addprefix $(PAREN), $(LIST))

all:
echo "$(LISTP)"

... is probably what you want.

1. Most special characters in GNU Make have to be parametrized and
often times $(subst)'ed in place of existing variables.


Wonder why some special characters are allowed to be escaped while some others
are not. For example, I can easily escape # like this:

LIST=a b c
LISTP=$(addprefix "\#", $(LIST))

all:
   echo $(LISTP)


2. Not inserting quotes around the echo string will result in shell
syntax failures because `(' is a delimiter in bourne shell.

Cheers,
-Garrett

It's no doubt an issue with how variables and functions are expanded. I'm sure Paul could better explain this phenomena.
HTH,
-Garrett



reply via email to

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