最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Makefile的make时传递参数的值中包含双引号

makefile crifan 6444浏览 0评论

折腾:

【已解决】Makefile中如何实现make时给变量传递参数如果没传用默认值

期间,此处的确是通过:

################################################################################

# Commit to github

################################################################################

m ?= “1. update book $(BOOK_NAME)”

GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io

## Commit generated files to github io

commit: all

  rsync -avzh –progress –stats –delete –force $(OUTPUT_PATH) $(GITHUB_IO_PATH)

  cd $(GITHUB_IO_PATH) && \

  pwd && \

  ls -la && \

  git status && \

  git add $(BOOK_NAME)/* && \

  git status && \

  git commit -m $(m) && \

  git status && \

  git push && \

  cd $(CURRENT_DIR) && \

  pwd

去实现make时传递参数去赋值给m了

make commit m=”1. update http summary”

但是结果好像是:

m=”1. update http summary”

被空格分开,作为多个参数了,导致报错:

error: pathspec ‘update’ did not match any file(s) known to git.

error: pathspec ‘http’ did not match any file(s) known to git.

error: pathspec ‘summary’ did not match any file(s) known to git.

make: *** [commit] Error 1

好像问题变成了:

make时传递参数的值中如何包含双引号

make pass parameters include quote

pass parameters include quote when make

windows – Escape double quotes in parameter – Stack Overflow

linux – bash: how to pass command line arguments containing special characters – Super User

说是用单引号’”xxx”‘?

去试试

make commit m='”1. update http summary book”‘

结果:

就可以了。

log输出中包含:

[master c39f085] 1. update http summary book

其中的

1. update http summary book

就是此处的-m参数的comments的值,是可以传入:

“1. update http summary book”

作为-m的参数的。

【总结】

此处,想要传递

“1. update http summary book”

给参数m,则可以使用单引号把带双引号的字符串包括起来:

make commit m='”1. update http summary book”‘

即可。

转载请注明:在路上 » 【已解决】Makefile的make时传递参数的值中包含双引号

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.172 seconds, using 22.07MB memory