On 13:34 Fri 05 Oct     , Steve Long wrote:
> Roy Marples wrote:
> > IFS=-
> > set -- ${CHOST}
> > spec=$2
> > 
> > Works fine in bash - and other shells.
> >
> Yeah fine, there are kludgy workarounds; so what? Doesn't mean I want to use
> them. ;)
> 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.

Avoiding externals at the cost of added complexity on something that 
only gets called one time certainly qualifies as premature optimization.

Thanks,
Donnie
-- 
[EMAIL PROTECTED] mailing list

Reply via email to