Why do we need "eval"? (Expect question)

Liste des GroupesRevenir à cl tcl 
Sujet : Why do we need "eval"? (Expect question)
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.lang.tcl
Date : 12. Sep 2024, 16:07:41
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vbv03t$1t4qm$1@news.xmission.com>
User-Agent : trn 4.0-test77 (Sep 1, 2010)
Consider this (Unix/Linux/bash) command line:

$ expect -- /dev/fd/3 3<<< 'eval spawn -noecho printf {{\t%s\n}} $argv;interact' $(seq 1 10)

This correctly generates the output (each line starts with a tab):

1
2
3
4
5
6
7
8
9
10

But notice how we have to use "eval" in order to split up the args in $argv.
And, since we are using "eval", we have to "double quote" (with {}) the
"format" arg to "printf".  It'd be nice if neither of these things were
necessary.

I've always believed that "eval" was "evil" and to be avoided if at all
possible - both in shell and in Tcl.  It has strange side effects, such as
we see here (the need to "double quote").  Is there any way to get the
above effect w/o using "eval" ?

--
"Every time Mitt opens his mouth, a swing state gets its wings."

(Should be on a bumper sticker)

Date Sujet#  Auteur
12 Sep 24 * Why do we need "eval"? (Expect question)11Kenny McCormack
12 Sep 24 `* Re: Why do we need "eval"? (Expect question)10Harald Oehlmann
12 Sep 24  +* Re: Why do we need "eval"? (Expect question)7Kenny McCormack
13 Sep 24  i+* Re: Why do we need "eval"? (Expect question)3Rich
13 Sep 24  ii+- Re: Why do we need "eval"? (Expect question)1Harald Oehlmann
13 Sep 24  ii`- Re: Why do we need "eval"? (Expect question)1Kenny McCormack
13 Sep 24  i`* Re: Why do we need "eval"? (Expect question)3Harald Oehlmann
13 Sep 24  i `* Re: Why do we need "eval"? (Expect question)2Kenny McCormack
13 Sep 24  i  `- Re: Why do we need "eval"? (Expect question)1Rich
13 Sep 24  `* Re: Why do we need "eval"? (Expect question)2Rich
13 Sep 24   `- Re: Why do we need "eval"? (Expect question)1Kenny McCormack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal