build.env-append working with merger in muniversal?

Ryan Schmidt ryandesign at macports.org
Wed Sep 15 13:47:26 PDT 2010


On Sep 15, 2010, at 08:50, Michael Dickens wrote:

> (2) In doing these experiments, I found that if I append the same environment variable more than once to build.env (or any other *.env), then only the last version is used -- and, no warnings or such are printed.  It's simple enough to check for this issue and print a warning; I'd also propose concatenating the various flags -- seems like a better solution than ignoring some.  Here's the diff that does both:
> 
> ++++++++++++++++++
> Index: base/src/port1.0/portutil.tcl
> ===================================================================
> --- base/src/port1.0/portutil.tcl       (revision 71479)
> +++ base/src/port1.0/portutil.tcl       (working copy)
> @@ -753,6 +753,12 @@
> 
>         while {[regexp "^(?: *)(\[^= \]+)=(\"|'|)(\[^\"'\]*?)\\2(?: +|$)(.*)$" ${the_environment} matchVar key delimiter value remaining]} {
>             set the_environment ${remaining}
> +            if {[info exists ${command}.env_array(${key})]} {
> +                ui_debug "Warning: Multiple values provided for ${command} environment variable '${key}'; concatenating them."
> +                set previous_key_val [set ${command}.env_array(${key})]
> +                set concat_val [concat ${previous_key_val} ${value}]
> +                set value [join ${concat_val} " "]
> +            }
>             set ${command}.env_array(${key}) ${value}
>         }
>     } else {
> 
> ++++++++++++++++++

Existing ports might depend on the existing behavior.

Though IMHO MacPorts is within its right to do it either way; behavior is IMHO undefined if you ask for the same env var to be appended multiple times with different values, and port authors should refrain from doing that.





More information about the macports-dev mailing list