From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15267 invoked from network); 13 Jan 2003 18:49:07 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Jan 2003 18:49:07 -0000 Received: (qmail 20175 invoked by alias); 13 Jan 2003 18:48:54 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5693 Received: (qmail 20164 invoked from network); 13 Jan 2003 18:48:53 -0000 From: "Bart Schaefer" Message-Id: <1030113184827.ZM21872@candle.brasslantern.com> Date: Mon, 13 Jan 2003 18:48:27 +0000 In-Reply-To: <15906.65149.206767.381472@fisica.ufpr.br> Comments: In reply to Carlos Carvalho "Re: aliases not getting expanded inside functions?" (Jan 13, 3:59pm) References: <15893.44217.393956.262362@fisica.ufpr.br> <20030103164552.A28966@globnix.org> <15893.50996.646711.184945@fisica.ufpr.br> <20030103184455.A5692@globnix.org> <15893.53780.524763.695176@fisica.ufpr.br> <20030103185407.GA11836@fysh.org> <15897.15986.562636.628562@fisica.ufpr.br> <1030106125404.ZM4660@candle.brasslantern.com> <15903.36155.716460.639226@fisica.ufpr.br> <1030111184020.ZM11764@candle.brasslantern.com> <15906.65149.206767.381472@fisica.ufpr.br> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: aliases not getting expanded inside functions? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 13, 3:59pm, Carlos Carvalho wrote: } } > fields=( "${(@s:;:)dataline}" ) # Answers your other question } } Doesn't work for me: Hrm. I was sure I'd tried it, but on your input I get the same result you do. Well, there's always: IFS=';' eval 'fields=( $=dataline )' However, it occurs to me that with dataline='...;";";...' -- that is, a quoted semicolon in the input data -- there's no quick solution that's going to do exactly what you need. } > while IFS=';' read rate capital etc. } } Yes, I didn't do it because I had hope to one day do a block move } via arrays. Also, reading to a parameter first makes it easier to do } some pre-processing like quote removal, otherwise I have to do it } field by field after reading. [...] } > fields[capital]=$((fields[capital]+fields[interest])) } } This makes the program more cumbersome to write and read because all } variables become quite long-named... So don't name the array "fields", name it "f" or some such. Three extra characters (e.g. $f[capital] instead of $capital) for a whole lot less complexity elsewhere. And quote removal may be as easy as: f=( ${${(kv)f#\"}%\"} ) (Whether it's actually that easy depends on your input data, e.g., you might also need to convert \" to ", but I think `read' will have done that for you already.)