From: Moritz Bunkus <moritz@bunkus.org>
To: zsh-users@zsh.org
Subject: regex matching regression in 5.0.0 vs. 4.3.17
Date: Sat, 15 Sep 2012 17:37:47 +0200 [thread overview]
Message-ID: <CANPayMThANJBYsnViEO6pC8RtQNXKLgCwyWuMa24JnZppBjLgA@mail.gmail.com> (raw)
Hey,
I've been using the following two lines inside a function whose output
is used in PS1. Basically: PS1="...$(parse_git_branch)..."
And the lines I'm talking about:
function parse_git_branch {
git_dir="$(git rev-parse --git-dir 2> /dev/null)"
branch_pattern="\*\s+([^${IFS}]+)"
no_branch_pattern="\*\s+\(no branch\)"
if [[ ${git_status} =~ ${no_branch_pattern} ]]; then
branch="detached"
elif [[ ${git_status} =~ ${branch_pattern} ]]; then
branch="${match[1]}"
elif [[ -f ${git_dir}/BISECT_LOG ]]; then
branch="${CLR_LIGHT_CYAN}bisecting"
fi
if [[ ! -z ${branch} ]]; then
echo " (${branch})"
fi
}
The idea is to get the current branch name if I'm inside a git repository.
This worked nicely with zsh 4.3.17 on my Ubuntu.
Now I wanted to use that same function on Arch Linux which is already
at zsh 5.0.0 and got the following error:
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).
I also made sure that this isn't Arch Linux specific by compiling zsh
5.0.0 from source on my Ubuntu machine (the one which usually runs
4.3.17). Same issue.
Replacing ${IFS} with \n gets rid of the error but does something
different than it did before if more than one local branch exists in a
git repository. Instead of just the current line ${match[1]} contains
everything starting from the current line until the end. Probably
because I don't escape that newline character properly.
So... any pointers? I'll try to bisect the actual change that caused
this, might take some time though.
Kind regards,
mosu
next reply other threads:[~2012-09-15 15:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-15 15:37 Moritz Bunkus [this message]
2012-09-15 19:42 ` Peter Stephenson
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=CANPayMThANJBYsnViEO6pC8RtQNXKLgCwyWuMa24JnZppBjLgA@mail.gmail.com \
--to=moritz@bunkus.org \
--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).