Looking for a cure for weird scope/memory of variables

Joshua Root jmr at macports.org
Tue Jul 9 14:19:10 PDT 2013


On 2013-7-10 03:56 , Clemens Lang wrote:
> On Tue, Jul 09, 2013 at 07:32:03PM +0200, Gustaf Neumann wrote:
>> foreach {foo.version foo.string} ${foo.versions} {
>>     subport foo-${foo.version} [subst {
>>         pre-fetch {
>>             system "echo ${foo.version}"
>>         }
>>         fetch {}
>>         extract {}
>>         use_configure no
>>         build {}
>>         destroot {}
>>     }]
>> }
> 
> I assume there is no sane way to guess what the user wants and somehow
> integrate this into the subport (and pre-fetch, etc.) procs, is there?
> 
> We could have a -subst switch, though:
>   subport -subst {
>     code
>   }

No need for that; using quotes instead of braces will achieve the same
thing. The trouble comes of course if you want to substitute some
variables at definition time and others at runtime (or at the top level
of the subport but not inside the pre-fetch or other internal
brace-wrapped string). I guess you could use 'format' on the body.

- Josh


More information about the macports-dev mailing list