Donnie Berkholz wrote:
> On 13:34 Fri 05 Oct     , Steve Long wrote:
>> In actual fact, I'd be more likely to use parameter expansion than set,
>> eg: spec=${CHOST#*-*-} # chop first two fields off so spec is fields 3 on
>> spec=${spec%%-*} # chop all but first off so left with just field 3
>> ..which I believe works in sh[1] as well. The point for me, however, is
>> not whether sh can be kludged to do something, it's what the most
>> efficient ways to do something in scripts are. Whether you use pe, read
>> or an array, avoiding externals leads to quicker scripts.[2]
> 
> That parameter workaround wouldn't work, because CHOST may also contain
> just 3 fields, as it does on Gentoo/BSD. Unpack a portage tarball and
> look at the make.conf's if you're curious.
>
Then the second expansion would have no effect.

> Avoiding externals at the cost of added complexity on something that
> only gets called one time certainly qualifies as premature optimization.
> 
True enough. It might be more relevant for eclasses, or maybe only for
actual bash scripts.


-- 
[EMAIL PROTECTED] mailing list

Reply via email to