Hmmm ...
Maybe my comment was referring to a different ksh feature than the
original post was concerned about. However, I would like further
confirmation about the capability of my post. I was working off the
subsection of the ksh man page at http://www2.research.att.com/sw/download/man/man1/ksh.html
that includes the following excerpt:
Finally a pattern can contain sub-patterns of the form
~(options :pattern-list ), where either options or :pattern-list can
be omitted. Unlike the other compound patterns, these sub-patterns are
not counted in the numbered sub-patterns. If options is present, it
can consist of one or more of the following:
+
Enable the following options. This is the default.
-
Disable the following options.
E
The remainder of the pattern uses extended regular expression
syntax like the egrep(1) command.
F
The remainder of the pattern uses fgrep(1) expression syntax.
G
The remainder of the pattern uses basic regular expression syntax
like the grep(1) command.
K
The remainder of the pattern uses shell pattern syntax. This is
the default.
N
This is ignored. However, when it is the first letter and is used
with file name generation, and no matches occur, the file pattern
expands to the empty string.
i
Treat the match as case insensitive.
g
File the longest match (greedy). This is the default.
l
Left anchor the pattern. This is the default for K style patterns.
r
Right anchor the pattern. This is the default for K style patterns.
If both options and :pattern-list are specified, then the options
apply only to pattern-list . Otherwise, these options remain in effect
until they are disabled by a subsequent ~(... ) or at the end of the
sub-pattern containing ~(... ).
On Mar 28, 2010, at 3:18 PM, ольга крыжановская wrote:
Its ~(options)pattern, not ~(options:pattern)
[[ 'x' == ~(G). ]] && print match
match
[[ 'x' == ~(G)x ]] && print match
match
Olga
2010/3/28 Dan Rickhoff <[email protected]>:
AST-Users
I also suspect that the ksh construct:
~(options :pattern-list )
is not working correctly. It doesn't seem to be interpreting the
grep-like
regular expression thingies that actually require some
interpretation.
For example, with an exact match, using no grep-like regular
expression thingies that require some interpretation, it works
correctly:
$ [[ 'x' == ~(G:x) ]]; print $?
0
However, changing the x (inside the parens) to a dot, so that we
use a
grep-like regular expression that does require some interpretation
(a simple
dot character, to match any single character), ksh does not
evaluate it as I
expect it to:
$ [[ 'x' == ~(G:.) ]]; print $?
1
Or am I misunderstanding the usage of:
~(options :pattern-list )
Dan
On Mar 28, 2010, at 12:55 AM, ольга крыжановская
wrote:
In Solaris ksh93 (which has xgrep as built in utility) I get this:
(builtin xgrep ; print -- "-a -C" | xgrep '(.*-a.*)&(.*-C.*)')
-a -C
Glenn, is ~(X) broken in ast-ksh.2010-03-09?
Olga
2010/3/28 ольга крыжановская
<[email protected]>:
OK, I am getting crazy (maybe): Can anyone explain why ksh -c 'x="-a
-C" ; [[ "$x" == ~(Xlr)(.*-a.*)&(.*-C.*) ]] && print true' does not
print 'true"? Xlr selects an augmented extended regular expression,
.*-a.* should be a match, .*-C.* should be a match and & means AND.
I'm banging my head since an hour against the problem with no
success.
HELP, please.
Olga
--
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ [email protected] \-`\-'----.
`'-..-| / Solaris/BSD//C/C++ programmer \ |-..-'`
/\/\ /\/\
`--` `--`
--
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ [email protected] \-`\-'----.
`'-..-| / Solaris/BSD//C/C++ programmer \ |-..-'`
/\/\ /\/\
`--` `--`
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users
--
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ [email protected] \-`\-'----.
`'-..-| / Solaris/BSD//C/C++ programmer \ |-..-'`
/\/\ /\/\
`--` `--`
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users