From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6264 invoked from network); 6 Jan 2003 08:30:23 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 Jan 2003 08:30:23 -0000 Received: (qmail 1273 invoked by alias); 6 Jan 2003 08:30:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5650 Received: (qmail 1213 invoked from network); 6 Jan 2003 08:30:03 -0000 From: Carlos Carvalho MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <15897.15986.562636.628562@fisica.ufpr.br> Date: Mon, 6 Jan 2003 06:29:38 -0200 To: zsh-users@sunsite.dk Subject: Re: aliases not getting expanded inside functions? In-Reply-To: <20030103185407.GA11836@fysh.org> 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> X-Mailer: VM 7.07 under Emacs 19.34.1 Zefram (zefram@fysh.org) wrote on 3 January 2003 18:54: >That's the "p" (*small* p) flag. Phil was demonstrating the "P" >(*capital* P) parameter expansion flag, which zshexpn(1) describes thus: > ># P This forces the value of the parameter name to be ># interpreted as a further parameter name, whose ># value will be used where appropriate. If used with ># a nested parameter or command substitution, the ... Oops... This didn't appear in my manual. After some digging I found that I was reading the old manual, for zsh 3, when this didn't exist yet. Now I've cleaned the remnants of the old installation and I can see the current manuals. Impressive! I'm starting to use some of the new features, but it's just the beginning :-) >To use this kind of parameter alias for setting, you can do ... >% : ${(P)foo::=xxx} >% echo ${(P)foo} >xxx >% echo $foo $bar >bar xxx > >which also works where foo is an array reference such as "array[3]". Thanks, I think I understood now. I wouldn't call it the simplest thing to find out... In my case I'd have to do % a[1]=name1 a[2]=name2 etc. % b[1]=b_name1 b[2]=b_name2 etc. and then to do the transfer for ((i=1; i< number-of-elements; i++)) { : ${(P)b[i]::=$a[i]} } However this is too much of a contortion to be useful... Is there a way to do the whole assignment without a loop? Something like ${(P)b::=$a} or similar (yes, this one cannot work of course). It seems that putting assignments like b_name1=$name1 b_name2=$name2 etc. in a function and simply calling it ends up working better. The only advantage of using the loop above is that it's independent of the number of elements, but I think this independence isn't worth the trouble. Thanks a lot to the developers in the list, the level of support is amazing.