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