Deutsch   English   Français   Italiano  
<vbv03t$1t4qm$1@news.xmission.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl
Subject: Why do we need "eval"? (Expect question)
Date: Thu, 12 Sep 2024 15:07:41 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vbv03t$1t4qm$1@news.xmission.com>
Injection-Date: Thu, 12 Sep 2024 15:07:41 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
	logging-data="2003798"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
Bytes: 1598
Lines: 30

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)