its regex syntax and doesn't need a quote
at http://pubs.opengroup.org/onlinepubs/9699919799/ set 9.3.5 item 7
from that it looks like
* if you want literal ']' use one of
        []...]
        [^]...]
* if you want literal '-' place it last
        [...-]

On Wed, 27 Jun 2012 17:43:06 +0200 Roland Mainz wrote:
> Hi!

> ----

> How can I quote '-' in a ~(Ex)-style pattern [...] that it exactly
> matches a '-' latter ?
> I've tried the following pattern but the result is wrong (it should
> match "hello-world" and "foo-bar"):
> -- snip --
> $ ~/bin/ksh -c 's="hello-world foo-bar" ;
> dummy="${s//~(Ex)([_\-[:alnum:]]+)/D}" ; print -v .sh.match'
> (
>         (
>                 hello
>                 world
>                 foo
>                 bar
>         )
>         (
>                 hello
>                 world
>                 foo
>                 bar
>         )
> )
> -- snip --
> I tried to quote the '\' with a 2nd '\' without success (e.g. we get
> the same wrong output/matches)
> -- snip --
> $ ~/bin/ksh -c 's="hello-world foo-bar" ;
> dummy="${s//~(Ex)([_\-[:alnum:]]+)/D}" ; print -v .sh.match'
> ...
> -- snip --

> Looking via dbx/gdb at the strings passed to the regex engine it looks
> like ksh93 is either passing no '\' to |_ast_regcomp()| (in the case
> of "~(Ex)([_\-[:alnum:]]+)") or it passes two '\' to |_ast_regcomp()|
> (in the case of "~(Ex)([_\\-[:alnum:]]+)") ... it looks like a bug in
> the ksh93 quoting mechanism for ~(E) patterns... ;-(

> The only working workaround I found is to use \x<hex> to avoid having
> to use \ to quote the '-' (the output below is IMO the expected one
> for "${s//~(Ex)([_\-[:alnum:]]+)/D}"):
> -- snip --
> $ ~/bin/ksh -c 's="hello-world foo-bar" ;
> dummy="${s//~(Ex)([_\x2d[:alnum:]]+)/D}" ; print -v .sh.match'
> (
>         (
>                 hello-world
>                 foo-bar
>         )
>         (
>                 hello-world
>                 foo-bar
>         )
> )
> -- snip --

> ----

> Bye,
> Roland

> -- 
>   __ .  . __
>  (o.\ \/ /.o) [email protected]
>   \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
>   /O /==\ O\  TEL +49 641 3992797
>  (;O/ \/ \O;)

> _______________________________________________
> ast-developers mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-developers

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to