Sujet : Re: Why do we need "eval"? (Expect question)
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.lang.tclDate : 13. Sep 2024, 12:26:10
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vc17gi$1u8fb$2@news.xmission.com>
References : 1 2 3
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
vc0ffk$ml8n$2@dont-email.me>, Rich <
rich@example.invalid> wrote:
Harald Oehlmann <wortkarg3@yahoo.com> wrote:
spawn -noecho printf {\t%s\n} {*}$argv
eventually, this works to:
spawn -noecho printf \t%s\n {*}$argv
>
Do note that the second one causes \t and \n to be interpreted by Tcl's
parser, so printf gets passed a literal tab and literal newline in its
parameter list. The first passes the \ and t characters on to printf,
and then printf does the interpretation.
>
Both likely work fine for printf, but may not work fine for all
possible external commands.
>
I think you misunderstand Harald's post (i.e., his notation).
The point is that if you pass {{\t%s\n}} to "eval", both sets of braces get
removed and what "printf" sees is (literally)
backslash tee percent ess backslash en
If you only pass a single level of braces, and eval it, then yes, as you
said, printf will see
tab percent ess newline
-- "Insisting on perfect safety is for people who don't have the balls to livein the real world." - Mary Shafer, NASA Ames Dryden -