I am new to Makefiles and was wondering if I could do something like this:
local-lint:
poetry run sqlfluff fix $(shell find . -name "$${ARG}" -not -path "./target/*") --show-lint-violations
then:
make local-lint ARG=myarg
I am new to Makefiles and was wondering if I could do something like this:
local-lint:
poetry run sqlfluff fix $(shell find . -name "$${ARG}" -not -path "./target/*") --show-lint-violations
then:
make local-lint ARG=myarg
You can, but not quite the way you use it here, but why use $(shell ...)? A recipe is already running in a shell, that's how make works (it invokes a shell to run the recipe). So you don't need to use make's shell function inside a shell script... it just adds confusion (IMO).
The first problem you have is that when you want to expand a make variable, like the ARG variable, you do not want to escape it. So your reference to ARG should just be $(ARG) or ${ARG} (they are equivalent) not $${ARG}.
But a better way to write this is to avoid the shell function, as I mentioned; you can do it like this:
local-lint:
poetry run sqlfluff fix `find . -name ${ARG} -not -path "./target/*"` --show-lint-violations
Or, if you prefer to use the newer shell syntax $(...) rather than backquotes you can but you need to escape the $ because you want the shell to see this:
local-lint:
poetry run sqlfluff fix $$(find . -name ${ARG} -not -path "./target/*") --show-lint-violations