Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: simple substitution?
- X-seq: zsh-users 14328
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: spiralofhope <spiralofhope@xxxxxxxxx>
- Subject: Re: simple substitution?
- Date: Thu, 27 Aug 2009 19:55:37 +0100
- Cc: zsh-users@xxxxxxxxxx
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=HEUfZvlzsxaTkUV6ULNoE5VK+Fyau5sQZiAsyw+yjWj72X3h+gyDSOyUm8zV6noMg5KZJaf7AOXaHxyk6Wi457AUTZcGut8Yrv5fSEc16fuXxoEuQVKSBK9kkYsza8PFxVMExGU6H+KBjOdRRi3OlHA4d2l70xYFv5bdmh7w6w0= ;
- In-reply-to: <20090827081235.176e8879@xxxxxxxxx>
- Mail-followup-to: spiralofhope <spiralofhope@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20090812133916.6ab5adcf.tartifola@xxxxxxxxx> <chaz20090812120418.GA21006@xxxxxxxxxxx> <20090827081235.176e8879@xxxxxxxxx>
2009-08-27 08:12:35 -0700, spiralofhope:
> On Wed, 12 Aug 2009 13:04:18 +0100
> Stephane Chazelas <stephane_chazelas@xxxxxxxx> wrote:
>
> > eval.
> >
> > eval "echo \${${FO}${O}}"
> >
> > or
> >
> > eval "echo \${$FO$O}"
> >
> > See also:
> >
> > echo ${(P)${:-$FO$O}}
> >
> > or
> >
> > echo ${(e)${:-\${$FO$O}}}
>
> Is eval a good idea? Can it introduce backdoors into the script?
Yes, that's usually what eval does when passed uncontrolled
data. You'd get the same problem with (e).
You need to make sure that $FO$O resolves to a valid variable
name.
if $FO$O were 'x}; rm -rf ${HOME' for instance, there'd be
damage.
However note that the eval solutions are standard POSIX sh
solutions, so you don't make your script zsh specific when using
them.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author