【发布时间】:2022-11-30 23:07:13
【问题描述】:
我写在Makefile
define deploy_meta
$(shell git log -n 2 --oneline | awk '{print "commit"NR ": " $0}')
commit: nogit-$(timestamp)
tag: nogit-$(timestamp)
deployed-from: $(shell hostname)
deployed-by: $(USER)
deploy-date: $(shell date -u '+%Y%m%d%H%M%S')
endef
但如果给我
$cat .deploy
commit1: commit2:
commit: nogit-1669806282
tag: nogit-1669806282
...
命令本身
git log -n 2 --oneline | awk '{print "commit"NR ": " $0}'
工作正常并给出两行。很明显,make 感觉到了,因为它打印了两个“commit#”字样。但它不打印内容。为什么?
【问题讨论】:
-
您命令中的
$0将由make解释。通过将$加倍来逃避它: ...$$0....