zsh-workers
 help / color / mirror / code / Atom feed
From: Eric Cook <llua@gmx.com>
To: zsh-workers@zsh.org
Subject: Re: Handling of escaped plus sign ("+") in regular expressions
Date: Wed, 20 May 2020 15:51:30 -0400	[thread overview]
Message-ID: <acb15383-b4ea-1e4f-7c47-dcd32bb93660@gmx.com> (raw)
In-Reply-To: <CAALaScm2RSFT9=FnWWEVXkkxV_KuSO9-z9Jv1NMeuex_9eF9TQ@mail.gmail.com>

On 5/20/20 3:18 PM, Marco Trevisan wrote:
> Hi,
>
> I've been using zsh to run some local scripts I was normally running with
> bash and while most of them work as expected, there's a case that weirdly
> failed to me (using zsh 5.8):
>
> [[ +123 =~ ^+[0-9]+$ ]]
> zsh: failed to compile regex: Invalid preceding regular expression
>
> [[ +123 =~ ^\+[0-9]+$ ]]
> zsh: failed to compile regex: Invalid preceding regular expression
>
> The same behavior seems to apply both using RE_MATCH_PCRE and not.
> As said, both matches correctly using bash.
>
> Using something like
>
> [[ +123 =~ ^[+][0-9]+$ ]]
>
> Works as expected instead.
>

bash's [[ =~ uses regex from the libc it was compiled against last time i checked.
and with libc's for the systems i have available, that won't work. it doesn't spit
out an error message like zsh does, but it correctly does not match the invalid regex.

  reply	other threads:[~2020-05-20 19:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 19:18 Marco Trevisan
2020-05-20 19:51 ` Eric Cook [this message]
2020-05-20 20:00   ` Eric Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acb15383-b4ea-1e4f-7c47-dcd32bb93660@gmx.com \
    --to=llua@gmx.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).