From: DervishD <zsh@dervishd.net>
To: Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@siemens.com>
Cc: zsh-users Mailinglist <zsh-users@sunsite.dk>
Subject: Re: Can I do without "eval" here?
Date: Tue, 14 Mar 2006 10:16:19 +0100 [thread overview]
Message-ID: <20060314091619.GA5940@DervishD> (raw)
In-Reply-To: <6F0CB04509C11D46A54232E852E390AC01004881@MCHP7R6A.ww002.siemens.net>
Hi Ronald :)
* Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@siemens.com> dixit:
> What I don't like in this example, is the usage of eval. Although
> it is harmless in this particular case, the filename 'foo', which
> is hardcoded here, comes in as a parameter too in my real
> application, and this means that it undergoes one level of
> evaluation too, which would yield wrong results when it contains,
> say, a $ character.
Try this:
eval whatevercommand \''$file'\'
As for doing the same without eval, it can be done, too, by
setting the sh_word_split option and tweaking, or simply with this:
options=("-x")
(($#)) && options=("-y" "$1")
CMD $options[1] $options[2] foo
If "foo" comes from a parameter, just use that parameter instead
of "foo".
I haven't tested the solution, so it may need some refinement,
but it should do.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to... RAmen!
next prev parent reply other threads:[~2006-03-14 9:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-14 9:03 Com MN PG P E B Consultant 3
2006-03-14 9:16 ` DervishD [this message]
2006-03-14 9:22 ` Michal Politowski
2006-03-14 9:42 ` DervishD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060314091619.GA5940@DervishD \
--to=zsh@dervishd.net \
--cc=mn-pg-p-e-b-consultant-3.com@siemens.com \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).