Today I Learned

3 posts about #commandline

Using $ sign inside of Makefile

I’ve just learned that if you want to use a dollar sign inside Makefile you need to escape $ with an extra $.

For example:

LATEST_COMMIT := $(shell git log --oneline | head -1 | awk '{print $1}')

It won’t work because make thinks that we are accessing make variable. If we want to use this awk command inside Makefile we need to escape the $

LATEST_COMMIT := $(shell git log --oneline | head -1 | awk '{print $$1}')