From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29813 invoked by alias); 5 Apr 2011 04:10:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28975 Received: (qmail 3355 invoked from network); 5 Apr 2011 04:10:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at np.by designates 91.149.189.205 as permitted sender) From: ZyX Reply-To: zyx@np.by To: zsh-workers@zsh.org Subject: Re: is variable with variable name possible? Date: Tue, 5 Apr 2011 08:09:59 +0400 User-Agent: KMail/1.13.5 (Linux/2.6.36-zen1; KDE/4.5.5; x86_64; ; ) References: <20110404162824.GB9371@yahoo.fr> In-Reply-To: MIME-Version: 1.0 Message-Id: <201104050809.59847@-zyx> Content-Type: multipart/signed; boundary="nextPart1629365.rkbjGqs2GC"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1629365.rkbjGqs2GC Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Reply to message =C2=ABRe: is variable with variable name possible?=C2=BB,= =20 sent 20:34:26 05 April 2011, Tuesday by Mikael Magnusson: > Pretty sure globsubst breaks your idea too, but fine, >=20 > : ${(P)~~somevar::=3D$PWD} >=20 > In fact, globsubst pretty much breaks every hook function i have :P. `emulate -L zsh' at the top of each function and it will be unbreakable by = such=20 options. Original message: > On 4 April 2011 18:28, Stephane Chazelas wro= te: > > 2011-04-04 16:25:01 +0200, Mikael Magnusson: > >> On 4 April 2011 16:06, Stephane Chazelas = =20 wrote: > >> > 2011-04-04 15:48:32 +0200, J=C3=A9r=C3=A9mie Roquet: > >> > [...] > >> >=20 > >> >> 2011/4/4 zzapper : > >> >> > somevar=3D$(pwd) > >> >> >=20 > >> >> > but I want somevar to be a variable name > >> >>=20 > >> >> $ eval "$somevar=3D$(pwd)" > >> >=20 > >> > [...] > >> >=20 > >> > No! > >> >=20 > >> > eval "$somevar=3D\$(pwd)" > >> > or > >> > eval "$somevar=3D\$PWD" > >> >=20 > >> >=20 > >> > Or think of what would happen if $PWD was "/tmp/x;rm -rf /home" > >>=20 > >> How do you feel about this? > >>=20 > >> : ${(P)somevar::=3D$PWD} > >=20 > > [...] > >=20 > > Try after > >=20 > > sudo ln -s . '/*' > > cd '/*/*/*/*/*' > > setopt globsubst > >=20 > > ;-) > >=20 > > (if you're lucky, it won't crash your machine). >=20 > Pretty sure globsubst breaks your idea too, but fine, >=20 > : ${(P)~~somevar::=3D$PWD} >=20 > In fact, globsubst pretty much breaks every hook function i have :P. --nextPart1629365.rkbjGqs2GC Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iEYEABECAAYFAk2alhcACgkQTFU0h8DxG4NQrgCfbYvI/6jZi1oiK6ffO8MWP296 BawAn0GrYguUqMQQ4jin+CPMTaf4jeRl =W/o4 -----END PGP SIGNATURE----- --nextPart1629365.rkbjGqs2GC--