From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24602 invoked from network); 10 Mar 2009 13:53:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Mar 2009 13:53:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 33820 invoked from network); 10 Mar 2009 13:52:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Mar 2009 13:52:10 -0000 Received: (qmail 2871 invoked by alias); 10 Mar 2009 13:52:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26707 Received: (qmail 2859 invoked from network); 10 Mar 2009 13:52:04 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 10 Mar 2009 13:52:04 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 6008F80307F8 for ; Tue, 10 Mar 2009 14:51:56 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly20d.srv.mailcontrol.com (MailControl) with ESMTP id n2ADpUYn030147 for ; Tue, 10 Mar 2009 13:51:53 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 10 Mar 2009 13:51:46 +0000 Date: Tue, 10 Mar 2009 13:51:46 +0000 From: Peter Stephenson To: zsh-workers Subject: Re: setopt globcomplete and () broken Message-ID: <20090310135146.30c0c794@news01> In-Reply-To: <237967ef0903100625s7e8e5908t7852ade0c1d6d8d3@mail.gmail.com> References: <237967ef0903100625s7e8e5908t7852ade0c1d6d8d3@mail.gmail.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Mar 2009 13:51:46.0599 (UTC) FILETIME=[5A64EB70:01C9A187] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.68.0.130 X-Virus-Scanned: ClamAV 0.92.1/9084/Tue Mar 10 08:11:13 2009 on bifrost X-Virus-Status: Clean On Tue, 10 Mar 2009 14:25:16 +0100 Mikael Magnusson wrote: > This is something that has been broken forever, but I never bothered > to look into exactly what broke it in my config. Today I got annoyed > enough though. > > zsh -f > % autoload compinit; compinit > % mkdir newdir; cd newdir > % touch '()' '().' > % touch > % touch \(\) > \(\) \(\). > % setopt globcomplete > % touch > % touch \(\) > # nothing appears > > I can only reproduce it with a pair of parentheses, just ( or ) > doesn't trigger it, but text can appear between them and still trigger > it. The oldest version I tried was 4.2.5 and the newest some days old > cvs. The following chunk of code in guess-where around line 201 is triggering: it's looking for glob qualifiers. We need a test that the parentheses aren't quoted; we could have '()' or "()" or $'()' or \(\), or some mixture, possibly with text in between. There is a slightly better test higher up, around line 17 (which correctly didn't trigger): that's newer code that I added when completing glob qualifiers. (The chunk of code below isn't completing them, it's trying to ensure they get applied.) Possibly copying the newer test here or putting it into a separate function would help, but I will wait for any cries of enlightenment before I do anything. It would be quite nice to have a test for the shell to decide "is character N in this command line argument a token or a metacharacter?" which isn't so much more than the context lex horrors already do... I suppose parse-partial-sexp is out of the question. if [[ -n "$compstate[pattern_match]" && ( ( -z "$SUFFIX" && "$PREFIX" = (|*[^\$])\([^\|\~]##\) ) || "$SUFFIX" = (|*[^\$])\([^\|\~]##\) ) ]]; then # Copy all glob qualifiers from the line to # the patterns used when generating matches if [[ "$SUFFIX" = *\([^\|\~]##\) ]]; then tmp3="${${(M)SUFFIX%\([^\|\~]##\)}[2,-2]}" SUFFIX="${SUFFIX%\($tmp3\)}" else tmp3="${${(M)PREFIX%\([^\|\~]##\)}[2,-2]}" PREFIX="${PREFIX%\($tmp3\)}" fi tmp2=() for tmp1 in "$pats[@]"; do if [[ "$tmp1" = (#b)(*[^\$])"(#q"(*)")" ]]; then tmp2=( "$tmp2[@]" "${match[1]}(#q${tmp3}${match[2]})" ) elif [[ "$tmp1" = (#b)(*[^\$])(\(\([^\|~]##\)\)) ]]; then tmp2=( "$tmp2[@]" "${match[1]}((${tmp3}${match[2][3,-1]}" ) elif [[ "$tmp1" = (#b)(*[^\$])(\([^\|~]##\)) ]]; then tmp2=( "$tmp2[@]" "${match[1]}(${tmp3}${match[2][2,-1]}" ) else tmp2=( "$tmp2[@]" "${tmp1}(${tmp3})" ) fi done pats=( "$tmp2[@]" ) fi -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070