在 Makefile 中将文件内容作为命令行参数传递

Passing a file content as command line parameter within a Makefile

为了将网页发布到 wordpress,我按以下方式使用 casperjs,从文件中读取两个参数:新网页和密码。

casperjs tools/wordpresspublish.js 1 "$(< html/數1.html)" $(< tools/wppwd)

在命令行下运行良好。现在我尝试在 Makefile 中做同样的事情:

.1.publ: 數1.html
   casperjs tools/wordpresspublish.js 1 "$(cat html/數1.html)" $(cat tools/wppwd)
   touch .1.publ

似乎以不同的方式解释 $。

这个怎么写?

你必须通过写两次来转义 $ 字符,像这样:

casperjs tools/wordpresspublish.js 1 "$$(< html/數1.html)" $$(< tools/wppwd)

另请注意,还有另一个字符必须转义:#。要转义它,请输入 \#.