From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: regex matching regression in 5.0.0 vs. 4.3.17
Date: Sat, 15 Sep 2012 20:42:46 +0100 [thread overview]
Message-ID: <20120915204246.0bb41f96@pws-pc.ntlworld.com> (raw)
In-Reply-To: <CANPayMThANJBYsnViEO6pC8RtQNXKLgCwyWuMa24JnZppBjLgA@mail.gmail.com>
On Sat, 15 Sep 2012 17:37:47 +0200
Moritz Bunkus <moritz@bunkus.org> wrote:
> parse_git_branch:8: failed to compile regex: Unmatched [ or [^
>
> Turned out it didn't like the ${IFS} inside the pattern (never mind
> the line number discrepency, I've cut out some other stuff from the
> function).
This simplifies to
[[ x =~ [^${IFS}] ]]
The problem is that IFS in zsh contains an ASCII null. As the regular
expression is a null-terminated string, it ends at that point, with the
error noted. The reason this has changed is that before the patch you
noted the null was left encoded as a space with an 8th-bit-set marker
before it; it didn't do the right thing, but as it was in a character
group you got away with it. So it's actually not a new breakage, just a
different one.
I'm not aware of any standard way of getting a null character into a
regular expression; they don't understand \0 or anything similar, and
presumably in any case regexec() hiccups in exactly the same way as
regcomp(). Even with pcre
[[ $'\x00' =~ '\x00' ]]
doesn't work (c.f. $'\x41' and '\x41' which does).
So unless anyone can think of a smart solution, I think the only answer
is to remove NULL characters from the body of the regular expression and
document that this happens.
You can do ${IFS//$'\0'} but it's not clear to me you should have to,
that use of IFS seems like it ought to work.
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2012-09-15 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-15 15:37 Moritz Bunkus
2012-09-15 19:42 ` Peter Stephenson [this message]
2012-09-15 21:12 ` Moritz Bunkus
2012-09-15 23:52 ` Phil Pennock
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=20120915204246.0bb41f96@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@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).