Re: Various FreeBSD bits...

Sean Chittenden
Tue, 13 Nov 2007 21:54:37 -0000

>> eg:  right now I use:
>>
>> class freebsd {
>>   $_cflags = $cflags ? { '''' =>
'''', default => $cflags }
>>   $_cxxflags = $cxxflags ? { '''' =>
'''', default => $cxxflags }
>>
>>   $_supfile = $supfile ? { '''' =>
''/etc/supfile'', default =>
>> $supfile }
>>   $_kernconf = $kernconf ? { '''' =>
''GENERIC'', default => $kernconf }
>>
>>   $_portsdir = $portsdir ? { '''' =>
''/usr/ports'', default =>
>> $portsdir }
>>   $_srcdir = $srcdir ? { '''' => /usr/src'',
default => $srcdir }
>>   $_objdir = $objdir ? { '''' => /usr/obj'',
default => $objdir }
>>   ...
>> }
>
> For the sake of all that is holy, USE A DEFINE!


Hrm... am I missing the clever way of doing:

define varfoo($var, $default) {
   $ret = "\$_${var} = \$${var} ? { '''' =>
''${default}'', default => \$$
{var} }
   eval $ret
}

class freebsd {
   varfoo {
     portsdir: var => ''portsdir'', default =>
''/default'';
   }

}

??  I need to create $_foo...  if I could turn of the immutability of
variables for a while and use $foo instead of $_foo, I''d be really
happy.  :)

$foo = ''/my/default'' if $foo == ''''

This would be cool and very welcome:

mother_doesnt_know_best {
   $foo = $foo ? { '''' => ''/my/default'',
default = $foo }
}

-sc


--
Sean Chittenden
sean@chittenden.org