作者:明卫国 | 来源:互联网 | 2023-09-18 14:19
BSDmakehasa:Qvariableexpansionmodifier,documentedintheFreeBSDmakemanpageasfollows:B
BSD make has a :Q
variable expansion modifier, documented in the FreeBSD make man page as follows:
BSD make有一个:Q变量扩展修饰符,在FreeBSD中有文档记录如下:
:Q Quotes every shell meta-character in the variable, so that it can be
passed safely through recursive invocations of make.
If variable var
has value a b\c"d'e$f
, then $(var:Q)
expands to a\ b\\c\"d\'e\$f
(or something equivalent). This is useful to pass strings to the shell without worrying that the shell will interpret any special characters.
如果变量var的值是b\c“d’e$f,那么$(var:Q)将会扩展到\ b\\ \\ $f(或类似的东西)。这有助于将字符串传递给shell,而不必担心shell将解释任何特殊字符。
Does GNU make have an equivalent? Or do I have to escape special characters my own?
GNU是否有一个等价的?还是我必须逃离自己的特殊角色?
2 个解决方案