1 |
On Tue, 2007-10-02 at 06:57 -0400, Mike Frysinger wrote: |
2 |
> > Pattern matching can be done just as well with case. Infact, tend to use |
3 |
> > [[ == ]] a lot when pattern matching when a case statement would be more |
4 |
> > efficient and use less code. Of course when you're just interested in |
5 |
> > matching one one thing in a code block then it uses more code, but that |
6 |
> > is probably outside the norm. |
7 |
> |
8 |
> case statements can be used in place of *some* statements, but not nearly all |
9 |
> and certainly does not provide the extended logic combining capabilities. |
10 |
> need to do boolean logic ? say hello to convoluted nested case statements! |
11 |
|
12 |
You can also do some pattern matching like so |
13 |
|
14 |
foo="foo foobar" |
15 |
|
16 |
[ "${foo%foobar}" = "${foo}" ] || echo "ends with foobar" |
17 |
[ "${foo#foobar}" = "${foo}" ] || echo "starts with foo" |
18 |
[ "${foo#* }" = "${foo}" ] || echo "has a space" |
19 |
|
20 |
So there's no need for convoluted nested case statements. |
21 |
|
22 |
Thanks |
23 |
|
24 |
Roy |
25 |
|
26 |
-- |
27 |
gentoo-dev@g.o mailing list |