![Makefile은 ``백틱 대신 $()를 사용합니다.](https://linux55.com/image/13803/Makefile%EC%9D%80%20%60%60%EB%B0%B1%ED%8B%B1%20%EB%8C%80%EC%8B%A0%20%24()%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%A9%EB%8B%88%EB%8B%A4..png)
$()
Makefile에서 쉘 확장 구문을 올바르게 이스케이프하는 방법은 무엇입니까 ?
.PHONY: test
test:
@if [ `find myDir -type f -not -name '*.openapi.yaml' | wc -l ` != 0 ]; then \
echo "All files must end with '.openapi.yaml'"; \
find myDir -type f -not -name '*.openapi.yaml'; \
exit 42; \
fi
내가 그것을 수정하려고 할 때
@if [ $( find myDir -type f -not -name '*.openapi.yaml' | wc -l ) != 0 ]; then \
알겠어요,
/bin/sh: line 0: [: !=: unary operator expected
탈출하려고 하면 $
같은 \$
오류가 발생합니다.
답변1
다음을 두 배로 늘려야 합니다 $
.
.PHONY: test test1 test2
test: test1 test2
test1:
@echo test1; if [ $$(echo 0) == "0" ]; then echo true; else echo false; fi
test2:
@echo test2; if [ $$(echo 0) == "1" ]; then echo true; else echo false; fi
예제를 실행해 보세요:
$ make
test1
true
test2
false