From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23608 invoked from network); 18 Aug 2000 09:12:55 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Aug 2000 09:12:55 -0000 Received: (qmail 18831 invoked by alias); 18 Aug 2000 09:12:41 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12676 Received: (qmail 18824 invoked from network); 18 Aug 2000 09:12:40 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer goliath.siemens.de) From: "Andrej Borsenkow" To: "ZSH workers mailing list" Subject: Question RE: SourceForge bug id 104052 - case study. Date: Fri, 18 Aug 2000 13:12:32 +0400 Message-ID: <000001c008f4$70ef7e80$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <000401c006ce$9a5e8810$21c9ca95@mow.siemens.ru> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal > > Case 2. > > bor@itsrm2% print $foo[\]] > ] > bor@itsrm2% print ${foo[\]]} > zsh: bad substitution > ... > > Case 2 comes from the fact, that paramsubst() and getindex() treat > both quoted > and unquoted brackets the same. The reason is (as I suspect) parameter > substitution in double-quotes - "$foo[bar]". When it is parsed by > dquote_parse(), it adds just plain ']' and not Outbrack; so, when it finally > reaches paramsubst() it may encounter both values. When inside of > parens, Zsh > just warns about missing closing one (because it finds end of > substitution too > early). > ... > > Case 2 - lexer should return different token for "]" as for \], > e.g. Qoutbrack > like Qstring. And, of course, all uses of ']'/Outbrack should be checked ... > but note, that in this case > > $foo[\]] > > will be valid, but > > "$foo[\]]" > > not. By definition, you cannot quote inside of double quotes. Even > > $foo["]"] > > will be invalid in this case (a bit unexpected), unless code can be smart > enough to notice, that initial Inbrack was not quoted. > This may work if we allow backslash to quote `]' inside of doublequotes. Because POSIX explcitly forbids it, it should be turned off at least in sh mode; so something like new option SH_STRICT_QUOTING is needed (or, probably, even POSIX_STRICT_QUOTING would be better name). That will make $foo[\]] and "$foo[\]]" both work and produce the same result. Neither sh nor ksh have this problem, as they do not have associated arrays; I could not compile new ksh so I do not know how it behaves. If there is no much con, I'll give it a try. -andrej