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
-- 
[EMAIL PROTECTED]     AIM: sethwklein     http://www.sethwklein.net/
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to