From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10866 invoked from network); 21 Feb 2005 12:05:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Feb 2005 12:05:22 -0000 Received: (qmail 87729 invoked from network); 21 Feb 2005 12:05:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Feb 2005 12:05:16 -0000 Received: (qmail 5541 invoked by alias); 21 Feb 2005 12:04:59 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8530 Received: (qmail 5527 invoked from network); 21 Feb 2005 12:04:59 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Feb 2005 12:04:58 -0000 Received: (qmail 86028 invoked from network); 21 Feb 2005 12:04:58 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 21 Feb 2005 12:04:54 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Mon, 21 Feb 2005 12:03:25 +0000 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 21 Feb 2005 12:05:43 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j1LC4qvr013777 for ; Mon, 21 Feb 2005 12:04:52 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j1LC4qp5013774 for ; Mon, 21 Feb 2005 12:04:52 GMT Message-Id: <200502211204.j1LC4qp5013774@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-users@sunsite.dk Subject: Re: zshexpn problem In-reply-to: <20050220060716.3a77bbb0@localhost> References: <20050220053335.4df75e1a@localhost> <20050220060716.3a77bbb0@localhost> Date: Mon, 21 Feb 2005 12:04:51 +0000 From: Peter Stephenson X-OriginalArrivalTime: 21 Feb 2005 12:05:43.0880 (UTC) FILETIME=[AB608C80:01C5180D] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.5 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.5 Matthias Berndt wrote: > On Sun, 20 Feb 2005 05:33:35 +0100 > Matthias Berndt wrote: > > > Hi, > > > > When LVERSION=2.6.10 ... why: > > print ${(s/./)LVERSION[2]} > > -> The s splitting happens late; it means the overall result of the expansion is an array. It doesn't mean the value is instantly turned into an array. (It's not evaluated simply left to right, for example.) There are a list of rules in the manual page for the order in which an expansion takes place at each level of nesting, and they have this order: 2. _Parameter Subscripting_ i.e. the [2] 8. _Forced Splitting_ i.e. the (s/./) So actually it's not well defined what happens in this case. Obviously, "documented" isn't the same as "clear". The following sentence is the key part of the documentation: Note that the Zsh Development Group accepts _no responsibility_ for any brain damage which may occur during the reading of the following rules. > > print ${${(s/./)LVERSION}[2]} > > -> 6 > > > > ... works 'correct', but is seems not very intelligent. That's the correct, logical way to do it, in as much as zsh is ever logical. Generate an expression which returns an array, then apply the subscript to that. Then rule 1 comes into force. 1. _Nested Substitution_ If multiple nested ${...} forms are present, substitution is performed from the inside outwards. At each level, the substitution takes account of whether the current value is a scalar or an array, whether the whole substitution is in double quotes, and what flags are supplied to the current level of substitution, just as if the nested substitution were the outermost. ... I still marvel that people complain about Perl being obscure. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************