On Tue, 2007-10-02 at 06:57 -0400, Mike Frysinger wrote:
> > Pattern matching can be done just as well with case. Infact, tend to use
> > [[ == ]] a lot when pattern matching when a case statement would be more
> > efficient and use less code. Of course when you're just interested in
> > matching one one thing in a code block then it uses more code, but that
> > is probably outside the norm.
> 
> case statements can be used in place of *some* statements, but not nearly all 
> and certainly does not provide the extended logic combining capabilities.  
> need to do boolean logic ?  say hello to convoluted nested case statements!

You can also do some pattern matching like so

foo="foo foobar"

[ "${foo%foobar}" = "${foo}" ] || echo "ends with foobar"
[ "${foo#foobar}" = "${foo}" ] || echo "starts with foo"
[ "${foo#* }" = "${foo}" ] || echo "has a space"

So there's no need for convoluted nested case statements.

Thanks

Roy

-- 
[EMAIL PROTECTED] mailing list

Reply via email to