From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23979 invoked by alias); 15 Sep 2012 15:46:17 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17266 Received: (qmail 19514 invoked from network); 15 Sep 2012 15:46:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at bunkus.org does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bunkus.org; s=mail201203; t=1347723468; bh=K8vGaZ3xf0ZmfPiUYuVuS9Ux3YeexmWZUOY7N/fZgyk=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=k6ml0gz6lisQTMklxR438cZcSq4mlK5ZmF4EHVShsQ1KDwtXyelgw/juJswOzQgXO 0ZKa2tsDcDpSDu5tcGMy088wxB9TV8YZNCys6Bpm8+RVmNdo7+nRCf8dKtN0GowbUl p7nPtSaP6jnuSIgsinOwi3SwnuJGSwuDuDAYg17k= MIME-Version: 1.0 Date: Sat, 15 Sep 2012 17:37:47 +0200 Message-ID: Subject: regex matching regression in 5.0.0 vs. 4.3.17 From: Moritz Bunkus To: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 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