On Tue, Nov 23, 2010 at 9:46 PM, Ethan Quach <[email protected]> wrote:
> Just one comment in net-fs-root.  Since the value grepped isn't actually
> needed, why not do what manifest-locator does at line 116 instead?
>
>   if [[ "$MEDIA" == ~(E)'^\$serverIP:' ]] ; then
[snip]

Erm... what exact do you want to do ? Should variable "serverIP" be an
extended regular expression or just a plain literal string ?
In the first case you AFAIK want [[ "$MEDIA" == ~(Elr)"$serverIP" ]]
to get an extended regular expression with left and right anchors ('^'
and '$' are normally parsed by the shell and do not end-up in the
regex as you may expect (with exceptions, see 'm' below)).
if you only want to match against a plain string you can do [[
"$MEDIA" == ~(F)"$serverIP" ]] to match any substring or [[ "$MEDIA"
== ~(Flr)"$serverIP" ]] to get left and right anchors (the 'f' in
~(<modifer>) means "fgrep" regex, the 'l' means left anchor and the
'r' means right anchor).

There are other choices like ~(X) and ~(A) for augumented regex (like
POSIX egrep regex but with "and" and "negation"), ~(P) for perl regex
(which is a long story to describe, short description can be found at
http://www.pcre.org/) and other options like 'i' for case-insensitive
matching, 'm' to enable '^' and '$' for multiline matches (across
newlines), 'g' to enable greedy matching and '-g' to disable it, 's'
to do "span matching' (usually used together with 'm' to match
newlines) ... details all on demand.
(with the next ksh93-integration update we get the ability to switch
between regex systems on-the-fly within a single sub-pattern)

ksh93 includes support for complex pattern capturing, too (details on
demand). For example:
-- snip --
$ ksh93 -c 'x="aaa bbb ccc" ; dummy="${x/~(E)(...) ((...)|(....))
(...)//}" ; print -v .sh.match'
(
        'aaa bbb ccc'
        aaa
        bbb
        bbb
        ''
        ccc
)
-- snip --
(".sh.match" is an indexed array, $ print -v arrayname # will print
the whole array content in one step)

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

Reply via email to