On Thu, May 6, 2010 at 5:39 PM, Jan Friedel <jan.frie...@sun.com> wrote: > > > Hi all, > > hope, I didn't write to the wrong alias. On the most recent > OpenSolaris build I run, say, the following set of commands in > my ksh93 script: > > typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" > print $(for i in ${f2cptr}; do print "${i/*[a-zA-Z\]]}"; done) > > The output is: arg1 2 3 4 > ,while the expected output is: 1 2 3 4 > > > Even more strange is the following case: > > typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" > print $(for i in ${f2cptr}; do print "${i/*[\]a-zA-Z]}"; done) > > The output is: arg1 [arg]2 [arg]3 [arg]4 > ,while the expected output is the same: 1 2 3 4 > > Any idea? It seems to be some kind of bug introduced sometime > recently in parsing mechanism of []. Thanks, > > /j.
I get the same for grep -E patterns: ksh93 -o noglob -c 'typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" ; for i in ${f2cptr} ; do print "${i/~(Eli)[a-z\[\]]*/}"; done' rg1 arg]2 arg]3 arg]4 Splitting the \] out of the [...] is a workaround: ksh93 -o noglob -c 'typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" ; for i in ${f2cptr} ; do print "${i/~(Eli)([a-z]|\[[a-z]*\])*/}"; done' 1 2 3 4 Using the shell OR operator @(a|b) works, too. a matches *[a-z] and b matches *[a-z]\] ksh93 -o noglob -c 'typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" ; for i in ${f2cptr} ; do print "${i/*@([a-z]|[a-z]\])}"; done' 1 2 3 4 Glenn, a bug for you: This is the same line as the last above but uses the ~(Si) prefix for case insensitive shell pattern. But it does not work: ksh93 -o noglob -c 'typeset f2cptr="arg1 [arg]2 [arg]3 [arg]4" ; for i in ${f2cptr} ; do print "${i/~(Si)*@([a-z]|[a-z]\])}"; done' arg1 [arg]2 [arg]3 [arg]4 Chris -- ^---^ (@)v(@) Chris Pickett | / IT consultant ===m==m=== pkch...@users.sourceforge.net _______________________________________________ ksh93-integration-discuss mailing list ksh93-integration-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss