From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18132 invoked from network); 18 Apr 2001 06:34:34 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Apr 2001 06:34:34 -0000 Received: (qmail 27455 invoked by alias); 18 Apr 2001 06:34:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14005 Received: (qmail 27441 invoked from network); 18 Apr 2001 06:34:28 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer goliath.siemens.de) Date: Tue, 17 Apr 2001 22:30:21 +0400 (MSD) From: Andrej Borsenkow X-X-Sender: To: Subject: Patterns quoting in subscript (was: Re: PATCH: Assorted parameter stuff) In-Reply-To: <1010415080610.ZM10250@candle.brasslantern.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 15 Apr 2001, Bart Schaefer wrote: > The main point of this patch is to address Andrej's message from last August > ("SourceForge bug id 104052 - case study") and related issues with parsing > array subscripts. Some other stuff got tweaked in passing. > > I'll hold off committing this until a couple of you have applied it and say > it seems OK. The "make check" tests all pass for me, at least (and it was > the completion tests, rather than the parameter tests, that gave it the best > workout). > At least one thing has changed (but I consider behaviour broken in anyway): bor@itsrm2:~%> foo=(a '?' '\?') bor@itsrm2:~%> print -r $foo[(r)?] a bor@itsrm2:~%> print -r $foo[(r)\?] ? bor@itsrm2:~%> print -r $foo[(r)\\?] ? bor@itsrm2:~%> print -r $foo[(r)\\\?] ? without patch you get: bor@itsrm2:~%> foo=(a '?' '\?') bor@itsrm2:~%> print -r $foo[(r)?] a bor@itsrm2:~%> print -r $foo[(r)\?] ? bor@itsrm2:~%> print -r $foo[(r)\\?] ? bor@itsrm2:~%> print -r $foo[(r)\\\?] \? bor@itsrm2:~%> print -r $foo[(r)\\\\?] \? bor@itsrm2:~%> print -r $foo[(r)\\\\\?] \? etc etc Both are broken. Without patch you have at least some (albeit completely unclear) possibility to quote patterns in subscript - with patch even this one is gone. I think, we have to decide on how quoting is actually done and finally implement it. I have very strong inclination to not reinvent te whell and simply use current quoting rules *including* $~foo (that as response to another message). We still need special treatment for patterns inside double quotes (else no subscripting is possible) - with this patch parsing of subscription is already done in seperate function so it should be possible. Suggestion is something like $foo[()pattern] - is parsed just like a "normal" globbing pattern, taking in account any quoting. I.e. in $foo[(r)\*$bar] neither ``*'' nor contents of $bar is taken as pattern. Special consideration is needed for double quotes. Because normally "$foo[(r)\?]" is parsed as *two* characters - ``\'' and ``?'', to allow quoting inside double-quotes extension of quoting rules is needed. I.e. ``\'' should be allowed to quote pattern metacharacters inside of subscript. I am not sure what impact it possibly have on compatibility ... OTOH if foo is array, zsh will always parse "$foo[*]" differently from /bin/sh even in compatibility mode. -andrej