Problems with option-replace modifier

Rainer Müller raimue at macports.org
Fri Sep 10 07:01:01 PDT 2010


>From <http://trac.macports.org/ticket/26421#comment:1>
>  I caused this by switching ImageMagick to use the new `-replace` syntax in
>  r70377. [...] [The] problem is that when I asked it to replace "`--with-x`" with
>  "`--without-x`" in the `configure.args`, in fact it replaced "`--with-
>  xml`" with "`--without-xml`". This demonstrates that using the `-replace`
>  feature is ill advised as it matches substrings.

That's true, -replace treats the option value as a string (using strsed)
and not as list. I didn't think of this when adding the feature and that
should be fixed.

I used strsed as I thought it would be shorter with backreferences, like
"s/--without-\(foobarbaz\)/--with-\1/", but matching word-boundaries is
complicated as strsed supports basic regex only.

To all Portfile writers:
Is there a need for -strsed at all or is it enough to have simple
replacements?

As a solution for the issue it would probably be better to have a plain
-replace taking two arguments. It would search for the first and replace
with the second, using the list form of the option (lsearch -exact,
lreplace). This would make it a real shorthand of -delete/-append.

While this would probably be the better approach for this modifier, it
would break existing Portfiles using the -replace feature.

To avoid breaking compatibility, I propose the following as a solution:

1. Rename existing -replace to -strsed
2. Treat -replace with one parameter like -strsed, but emit a
   deprecation warning
3. Add new -replace taking two arguments as described above

Opinions?

Rainer


More information about the macports-dev mailing list