Home > Backend Development > Golang > Why Aren't My Makefile Expressions Evaluating Correctly?

Why Aren't My Makefile Expressions Evaluating Correctly?

Mary-Kate Olsen
Release: 2024-12-20 19:32:11
Original
823 people have browsed it

Why Aren't My Makefile Expressions Evaluating Correctly?

Evaluating Expressions in Makefile Commands

Makefiles are powerful tools for automating build processes. However, when writing Makefile recipes, it's important to understand how expressions are evaluated.

In a Makefile recipe section, the dollar sign ($) is used to interpolate variables. To interpolate an expression that involves a command, you need to escape the $ using a second $:

Problem: Using an expression in a Makefile command, but the expression is not being evaluated.

Command:

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

Issue: The expression is enclosed in parentheses, which prevents it from being expanded.

Solution: Escape the dollar sign using another dollar sign ($):

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

Now, the Makefile will correctly evaluate the expression and run the go test command with the filtered test files.

The above is the detailed content of Why Aren't My Makefile Expressions Evaluating Correctly?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template