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

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Why do we need "eval"? (Expect question)
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.lang.tcl
Date : 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 live
in the real world."

    - Mary Shafer, NASA Ames Dryden -

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