gpt4 book ai didi

bash - 如何转义 autoconf/m4 中的文本?

转载 作者:行者123 更新时间:2023-11-29 08:49:51 26 4
gpt4 key购买 nike

我的 configuration.ac 文件中的以下代码不起作用(请注意带有 [default=no] 的嵌套方括号):

AC_ARG_ENABLE(debug,
[ --enable-debug build with debugging support [default=no].],
[DEBUG="$enableval"],
[DEBUG="no"]
)

我怎样才能避开这些括号?

最佳答案

找到了!来自 this教程:

M4 arguments are quoted with [ and ]. There is NO WAY to escape these, however, you have several options if you wish to insert ['s or ]'s:

  1. Use a `Quadrigraph'. @<:@ gives you [ and @:>@ gives you ].
  2. Balance your quotes. M4 will turn [[]] in to []. Beware of using this in arguments to macros. Sometimes, you need to double quote as well ([[[]]]).
  3. Change the quoting using: changequote(<<,>>) to change the quoting to << and >>. The autoconf documentation (rightly, in my opinion) warns against the (over) use of this, since it can lead to unexpected results.
  4. Avoid [ and ] where ever possible. This is my personal choice.

因此我的新代码是:

AC_ARG_ENABLE(debug,
AS_HELP_STRING(
[--enable-debug],
[build with debugging symbols @<:@default=no@:>@]),
[enable_debug="$enableval"],
[enable_debug="no"]
)

关于bash - 如何转义 autoconf/m4 中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2308721/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com