3
votes

Description:

I have the following snippet within my GNU makefile:

test:=$(shell grep '#pragma' test_types.h)
$(info test:$(test))

The above results in the following error message:

*** unterminated call to function 'shell': missing ')'. STOP

However if I remove the '#' from the snippet above:

test:=$(shell grep 'pragma' test_types.h)
$(info test:$(test))

The output is:

test: #pragma pack(push, 1) #pragma pack(pop)

If I run the following directly from the command line: grep '#pragma' test_types.h. The output is again:

#pragma pack(push, 1) #pragma pack(pop)

Question:

What is causing the shell function behaviour when combining grep with a search for # within a GNU makefile?

1
Try putting a backslash in front of the # because it is causing the rest of the line to be treated as a comment.Mark Setchell

1 Answers

7
votes

It is interpreting the # as the start of a comment, so the rest of the line is no longer seen.

Escape the character as # instead and it will work.