:C colon-C 在 FreeBSD make 中是什么意思?
What does :C colon-C mean in FreeBSD make?
我的公司使用 FreeBSD,因此使用 FreeBSD 的 make。
我们的一些内部端口包括这样的东西(其中 BRANCH 是来自 SVN URL,'trunk' 或像 'branches/1.2.3' 这样的分支名称的东西) .
PORTVERSION= ${BRANCH:C,^branches/,,}
make(1)
的 变量修饰符 部分将 :C
冒号-c 修饰符记录为
:C/pattern/replacement/[1gW]
我在看正确的文档吗? ^branches/
对我来说看起来像一个正则表达式 pattern,但看起来实际代码使用 ,
而不是 /
作为分隔符。我是否跳过了对此进行解释的文档?
:C/pattern/replacement/[1gW]
The :C modifier is just like the :S modifier except that the old and new strings, instead of being simple strings, are an extended regular expression (see regex(3)) string pattern and an ed(1)-style string replacement.
并在 :S
中:
Any character may be used as a delimiter for the parts of the modifier string.
正如@MadScientist 指出的那样,使用不同的定界符是很常见的,尤其是当 /
是模式或替换字符串的一部分时,就像您的情况一样。否则它将需要转义并且看起来像 ${BRANCH:C/^branches\///}
这似乎不太可读。
我的公司使用 FreeBSD,因此使用 FreeBSD 的 make。
我们的一些内部端口包括这样的东西(其中 BRANCH 是来自 SVN URL,'trunk' 或像 'branches/1.2.3' 这样的分支名称的东西) .
PORTVERSION= ${BRANCH:C,^branches/,,}
make(1)
的 变量修饰符 部分将 :C
冒号-c 修饰符记录为
:C/pattern/replacement/[1gW]
我在看正确的文档吗? ^branches/
对我来说看起来像一个正则表达式 pattern,但看起来实际代码使用 ,
而不是 /
作为分隔符。我是否跳过了对此进行解释的文档?
:C/pattern/replacement/[1gW]
The :C modifier is just like the :S modifier except that the old and new strings, instead of being simple strings, are an extended regular expression (see regex(3)) string pattern and an ed(1)-style string replacement.
并在 :S
中:
Any character may be used as a delimiter for the parts of the modifier string.
正如@MadScientist 指出的那样,使用不同的定界符是很常见的,尤其是当 /
是模式或替换字符串的一部分时,就像您的情况一样。否则它将需要转义并且看起来像 ${BRANCH:C/^branches\///}
这似乎不太可读。