From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6329 invoked by alias); 16 Dec 2013 22:08:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32136 Received: (qmail 17151 invoked from network); 16 Dec 2013 22:08:53 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=Xt3shx27rjBTQ9L2xqYXEgvKVFSHTG7LZEw+ETPlPVg=; b=FXVzqo7g2ycLxmpBr3tkoUhqixI9rK8jfFUK9R6347K1xx4vOYKE8T+vDNVTwlt3Px TnfMzKbDxxjvpKDwafJNGwUxUwgD5sVbqkqG3nfLzT7Lg/Du5f4UrVBq8k/TsvezrqYa cn9FvACFDyWMW2k3m5gqKhrRvmBdIcVK/A3Fm1jKm/l1sRAk+yUsdxiNZ8OS+aS+qsj2 1VJX47FkicubUHtM/QeDVPjS4LCYtQl1bIAoLeeAT1N8yazhixZoazbq4MswE14pO3Jz 9FKSJ9bfNAOTWMZeuklczXSJpYzttiUQ5NC+xOaZ1WDyMqbxCAAynJaUE1aHO1yTUODf 2LVQ== X-Gm-Message-State: ALoCoQmGE4kM/dF+vBqS1LhilR8ENYA5gE09Wpy7V645mECdANTOQQz1sJfmoBh/FP/0sbKDesAT X-Received: by 10.180.36.40 with SMTP id n8mr151071wij.54.1387231728360; Mon, 16 Dec 2013 14:08:48 -0800 (PST) X-ProxyUser-IP: 86.6.157.246 Date: Mon, 16 Dec 2013 22:08:45 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: 5.0.3 +* -> git completion regression Message-ID: <20131216220845.2108e18b@pws-pc.ntlworld.com> In-Reply-To: <20131216103726.GA25715@redoubt.spodhuis.org> References: <20131216081436.GA23085@redoubt.spodhuis.org> <20131216094700.2c5edd2a@pwslap01u.europe.root.pri> <20131216103726.GA25715@redoubt.spodhuis.org> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 16 Dec 2013 05:37:26 -0500 Phil Pennock wrote: > On 2013-12-16 at 09:47 +0000, Peter Stephenson wrote: > > On Mon, 16 Dec 2013 03:14:37 -0500 > > Phil Pennock wrote: > > > % git push origin > > > __git_complete_remote_or_refspec:33: bad pattern: +* > > > > I can't think of any circumstance where +* should be a bad pattern. Is > > this easy to reproduce in a simple example? > > Finally managed it. It seems that the _git wrapper has a function > __git_zsh_bash_func() which does "emulate -L ksh" and somehow that > breaks when calling into the functions, while sourcing the file under > sticky sh emulation (via "emulate sh -c") overrides that ksh context and > fixes this. > > % zsh -f > ilmenite% emulate ksh > ilmenite% case "$foo" in +*) echo snert;; esac > zsh: bad pattern: +* Thanks. This is an efficient fix, so I hope it's good enough --- I've added a regression test, and it seems to be. Another good workout with some sh scripts or functions would be useful. diff --git a/Src/pattern.c b/Src/pattern.c index a7ef125..b79c3b4 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -1265,12 +1265,18 @@ patcomppiece(int *flagp, int paren) * the character following is an end-of-segment character. Thus * tildes are not special if there is nothing following to * be excluded. + * + * Don't look for X()-style kshglobs at this point; we've + * checked above for the case with parentheses and we don't + * want to match without parentheses. */ - if (kshchar || (memchr(zpc_special, *patparse, ZPC_COUNT) && - (*patparse != zpc_special[ZPC_TILDE] || - patparse[1] == '/' || - !memchr(zpc_special, patparse[1], ZPC_SEG_COUNT)))) + if (kshchar || + (memchr(zpc_special, *patparse, ZPC_NO_KSH_GLOB) && + (*patparse != zpc_special[ZPC_TILDE] || + patparse[1] == '/' || + !memchr(zpc_special, patparse[1], ZPC_SEG_COUNT)))) { break; + } } /* Remember the previous character for backtracking */ diff --git a/Src/zsh.h b/Src/zsh.h index a935d23..c86d2a6 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1417,7 +1417,11 @@ enum zpc_chars { ZPC_HAT, /* ^ for exclusion (extended glob) */ ZPC_HASH, /* # for repetition (extended glob) */ ZPC_BNULLKEEP, /* Special backslashed null not removed */ - ZPC_KSH_QUEST, /* ? for ?(...) in KSH_GLOB */ + /* + * These characters are only valid before a parenthesis + */ + ZPC_NO_KSH_GLOB, + ZPC_KSH_QUEST = ZPC_NO_KSH_GLOB, /* ? for ?(...) in KSH_GLOB */ ZPC_KSH_STAR, /* * for *(...) in KSH_GLOB */ ZPC_KSH_PLUS, /* + for +(...) in KSH_GLOB */ ZPC_KSH_BANG, /* ! for !(...) in KSH_GLOB */ diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 81b0021..1f8f652 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -499,3 +499,30 @@ ) 0:No error with empty null glob with (N). > + + (setopt kshglob + test_array=( + '+fours' '+*' + '@titude' '@*' + '!bang' '!*' + # and check they work in the real kshglob cases too... + '+bus+bus' '+(+bus|-car)' + '@sinhats' '@(@sinhats|wrensinfens)' + '!kerror' '!(!somethingelse)' + # and these don't match, to be sure + '+more' '+(+less)' + '@all@all' '@(@all)' + '!goesitall' '!(!goesitall)' + ) + for str pat in $test_array; do + eval "[[ $str = $pat ]]" && print "$str matches $pat" + done + true + ) +0:kshglob option does not break +, @, ! without following open parenthesis +>+fours matches +* +>@titude matches @* +>!bang matches !* +>+bus+bus matches +(+bus|-car) +>@sinhats matches @(@sinhats|wrensinfens) +>!kerror matches !(!somethingelse) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/