whoi
whoi

Reputation: 3421

How to print #(sharp sign) in a Makefile

Suppose you have a variable which is set as:

AVar = "#"

echo "${AVar}"

The above thing does not output in Makefile when run through make.

# must be escaped but the AVar may not have special chars in its content?

So what can I escape the Avar?

Upvotes: 1

Views: 1239

Answers (1)

Alnitak
Alnitak

Reputation: 339786

Tested working with GNU Make 3.81 on MacOS X:

AVar = "\#"

foo:
    @echo "${AVar}"

I'm not sure what you mean by "AVar may not have special chars in its content". In this case it's the only way to tell make that the # is part of the string, and not the start of a comment.

Upvotes: 2

Related Questions