From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14699 invoked from network); 3 Jan 2003 17:45:12 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Jan 2003 17:45:12 -0000 Received: (qmail 16013 invoked by alias); 3 Jan 2003 17:44:56 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5645 Received: (qmail 16000 invoked from network); 3 Jan 2003 17:44:55 -0000 Date: Fri, 3 Jan 2003 18:44:55 +0100 From: Phil Pennock To: zsh-users@sunsite.dk Subject: Re: aliases not getting expanded inside functions? Message-ID: <20030103184455.A5692@globnix.org> Mail-Followup-To: zsh-users@sunsite.dk References: <15893.44217.393956.262362@fisica.ufpr.br> <20030103164552.A28966@globnix.org> <15893.50996.646711.184945@fisica.ufpr.br> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <15893.50996.646711.184945@fisica.ufpr.br>; from carlos@fisica.ufpr.br on Fri, Jan 03, 2003 at 03:24:04PM -0200 X-Disclaimer: Any views expressed in this message, where not explicitly attributed otherwise, are mine and mine alone. Such views do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2003-01-03 at 15:24 -0200, Carlos Carvalho wrote: > Phil Pennock (Phil.Pennock@globnix.org) wrote on 3 January 2003 16:45: > >% bar=3D'Fred Bloggs' > >% foo=3D'bar' > >% function escr { print ${(P)foo} } > >% escr > >Fred Bloggs > > > >Is the above sufficient? >=20 > Unfortunately no, because I don't need it only for printing, but for > referencing as well. I have an array and I'd like to access the > elements by more meaningful names, so I tried to do >=20 > % alias -g guess_what=3D'array[1]', etc. >=20 > Your suggestion doesn't work however when an assignment has to be made > to guess_what. >=20 > >You might wish to read zshexpn(1), since there are many other weird and > >wonderful ways in which zsh can pervert your data on demand. >=20 > I did but didn't see this possibility. In fact I still don't see... > What's the relation between recognizing the same escape sequences as > print and making a substitution? I'd be grateful for an explanation. print is merely what was used for showing the results. The variable substitution does not rely upon print. % set -A array alpha beta gamma delta epsilon zeta % guess_what=3D'array[3]' % echo ${(P)guess_what} gamma % guess_what=3D'array[4]' % echo ${(P)guess_what} delta % guess_what=3D'array[1]' % for i in $(perl -le "print foreach split //, '${(P)guess_what}'") ; echo = $i a l p h a % My suggestion appears to work, independent of echo/print. :^) I think that you're confusing "print -P", which recognises the same escape sequences as are used in prompt substitution, with the parameter expansion flag 'P', which is described in zshexpn(1). --=20 "We've got a patent on the conquering of a country through the use of force. We believe in world peace through extortionate license fees." -- Andy Fors= ter --jI8keyz6grp/JLjh Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (OpenBSD) iD8DBQE+FcwWfDS04Uzk9lURArH0AJ4rmYV0QErQWSwlulfa1EyAriD9+gCgiIqt ME3ebg+iESsHnXWvP622xRM= =xOm7 -----END PGP SIGNATURE----- --jI8keyz6grp/JLjh--