"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Doesn't My Makefile Interpolate Expressions in $(())?

Why Doesn't My Makefile Interpolate Expressions in $(())?

Posted on 2025-03-25
Browse:203

Why Doesn't My Makefile Interpolate Expressions in $(())?

Makefile Interpolation Issue

When attempting to interpolate an expression within a Makefile command, it remains unevaluated. This occurs when the expression is enclosed in double curly brackets $(()).

To resolve this issue, double the dollar sign ($) within the recipe section of the Makefile. This effectively escapes the first dollar sign, allowing for proper interpolation.

Here's an example of a corrected Makefile:

test:
    go test $$(go list ./... | grep -v /vendor/)

.PHONY: test

With this modification, the expression $$(go list ./... | grep -v /vendor/) will be evaluated properly when running the make test command.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3