Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Extending regexes



On Wed, Jul 6, 2022 at 4:13 PM Phil Pennock
<zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
>
> A while back I wrote some bindings for using the RE2 library [...]
>
> My _tentative_ thinking, which I'd appreciate feedback on, is to
> introduce a new special parameter, `ZSH_EQTILDE_ENGINE` or somesuch;
> [...]
>
> Is this sane?  Are we happy introducing new special parameters, as long
> as the name starts `zsh`?  [...]

My intuition about this suggests that an interface somewhere between
"enable -p $patchar" and "ztie -d $dbtype" would be more appropriate
here.  Something like

zregex zsh/re/$flavor

where the named module must implement "-$flavor-match" as a
conditional.  For backwards-compatibility, zsh/pcre would load
zsh/re/pcre and zsh/regex would load zsh/re/regex.

An option "zregex -x" (choose your x) replaces -regex-match with
-$flavor-match (a no-op for zsh/re/regex) in the implementation of
"=~"

Leave RE_MATCH_PCRE as-is (it replaces -$flavor-match with -pcre-match
when set) but document it as deprecated and perhaps print a warning if
that option is set when zregex -x is called.




Messages sorted by: Reverse Date, Date, Thread, Author