My company uses FreeBSD, and therefore FreeBSD's flavor of make.
A few of our in-house ports include something like this (where BRANCH is something that came from an SVN URL, either 'trunk' or a branch name like 'branches/1.2.3').
PORTVERSION= ${BRANCH:C,^branches/,,}
The Variable modifiers section of make(1)
documents the :C
colon-c modifier as
:C/pattern/replacement/[1gW]
Am I looking at the right documentation? ^branches/
looks like a regex pattern to me, but it looks like the actual code uses ,
instead of /
as a separator. Did I skip documentation explaining that?
The documentation says:
and in
:S
:As @MadScientist pointed out, it's quite common to use a different delimiter, especially when
/
is a part of pattern or replacement string, like in your case. Otherwise it would require escaping and would look like${BRANCH:C/^branches\///}
which seems less readable.