jhalfs: Ready to go.

Seth W. Klein sk at sethwklein.net
Sun Oct 16 11:13:56 PDT 2005


On Fri, Oct 14, 2005 at 09:15:24AM -0400, Jeremy Huntwork wrote:
> Alexander E. Patrakov wrote:
> >
> >[....]
> >
> >if [ "$i" = "082-groff" ] ; then {do something} ; fi.
> >
> >[....]
> 
> Yep, I completely agree. The line above, for example, could probably read:
> 
> if echo $i | grep -q "groff" ; then ... ; fi
> 
> Other suggestions are welcome.

That is, in the general case, broken due to quoting.  Try:

    if echo "$i" | grep -q groff ; then ... ; fi

(grep -q isn't portable, either, but you may not care.)

In any case, the following is portable and fast.  (Forks are expensive
and grep is never a builtin.)

    case $i in *groff) ... ;; esac

Sometimes it is nice that the ;; can be omitted if there is only one
case as in:

    case $i in *groff)
	.
	.
	.
    esac

Cheers,
Seth W. Klein
-- 
sk at sethwklein.net     AIM: sethwklein     http://www.sethwklein.net/



More information about the lfs-dev mailing list