如何在 Makefile 中用空格替换单引号

发布于 2024-10-13 04:10:40 字数 169 浏览 1 评论 0原文

我可以用 GNU makefile 中的任何其他内容替换任何内容。但无法弄清楚如何用空格替换单引号。 任何帮助!

编辑:我尝试过这样的事情:

$(subst \', :, $(text))

在上面我尝试用冒号替换单引号,但它似乎不起作用。

I am able to replace anything with anything else in a GNU makefile. But can't work out how to replace single-quote with spaces.
Any help!

EDIT: I have tried something like this:

$(subst \', :, $(text))

In above I am trying to replace single-quotes with colons, but it doesn't seem to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东风软 2024-10-20 04:10:40

似乎按预期工作:

$ cat Makefile
FOO="'"
BAR=$(subst ', :,$(FOO))
BAZ="This 'is 'some 'te'xt' wi't'h in'ter'sper'sed' apo'stro'phe's"
QUX=$(subst ', ,${BAZ})
ARF=$(subst ',:,$(BAZ))

.PHONY: all
all:
        @echo FOO = ${FOO}
        @echo BAR = ${BAR}
        @echo BAZ = ${BAZ}
        @echo QUX = ${QUX}
        @echo ARF = ${ARF}

$ make
FOO = '
BAR =  :
BAZ = This 'is 'some 'te'xt' wi't'h in'ter'sper'sed' apo'stro'phe's
QUX = This  is  some  te xt  wi t h in ter sper sed  apo stro phe s
ARF = This :is :some :te:xt: wi:t:h in:ter:sper:sed: apo:stro:phe:s

Seems to work as expected:

$ cat Makefile
FOO="'"
BAR=$(subst ', :,$(FOO))
BAZ="This 'is 'some 'te'xt' wi't'h in'ter'sper'sed' apo'stro'phe's"
QUX=$(subst ', ,${BAZ})
ARF=$(subst ',:,$(BAZ))

.PHONY: all
all:
        @echo FOO = ${FOO}
        @echo BAR = ${BAR}
        @echo BAZ = ${BAZ}
        @echo QUX = ${QUX}
        @echo ARF = ${ARF}

$ make
FOO = '
BAR =  :
BAZ = This 'is 'some 'te'xt' wi't'h in'ter'sper'sed' apo'stro'phe's
QUX = This  is  some  te xt  wi t h in ter sper sed  apo stro phe s
ARF = This :is :some :te:xt: wi:t:h in:ter:sper:sed: apo:stro:phe:s
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文