Gentoo Archives: gentoo-dev

From: Roy Marples <uberlord@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] RFC: sh versionator.eclass
Date: Wed, 03 Oct 2007 12:52:14
Message-Id: 1191415227.1108.25.camel@uberlaptop.development.ltl
In Reply to: Re: [gentoo-dev] RFC: sh versionator.eclass by Mike Frysinger
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

Replies

Subject Author
Re: [gentoo-dev] RFC: sh versionator.eclass Mike Frysinger <vapier@g.o>