Re: passing tcl list to args of an external program
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 29 Nov 2007 19:25:55 GMT
At 2007-11-29 08:36AM, "Anon432 Vqfz" wrote:
Consider this bash test script:
$ bash -c 'for f;do echo "myarg: $f";done' TESTSCRIPT 'first arg' 'second arg'
myarg: first arg
myarg: second arg
How might I drive the arguments sent to the
above script with a tcl list? I want the method
to to be generic enough, so it does
not matter what is in the list.
For tcl 8.4
% set params [list {first arg} {second arg}]
{first arg} {second arg}
% set cmd [linsert $params 0 bash -c {for f;do echo "$0 arg: $f";done} TESTSCRIPT]
bash -c {for f;do echo "$0 arg: $f";done} TESTSCRIPT {first arg} {second arg}
% catch [linsert $cmd 0 exec] output
0
% set output
TESTSCRIPT arg: first arg
TESTSCRIPT arg: second arg
for tcl 8.5
% set params [list {first arg} {second arg}]
{first arg} {second arg}
% set cmdpref [list bash -c {for f;do echo "$0 arg: $f";done} TESTSCRIPT]
bash -c {for f;do echo "$0 arg: $f";done} TESTSCRIPT
% catch [list exec {*}$cmdpref {*}$params] output
0
% set output
TESTSCRIPT arg: first arg
TESTSCRIPT arg: second arg
The only approaches that seem to work for me, involve
figuring out a way to metaquote the arguments when required.
But, I'm inexperienced w/tcl.
I use this to think about quoting in Tcl:
shell quoting: "double $interpolates", 'single $does_not'
Tcl quoting: "double $interpolates", {braces $dont}
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.
- References:
- passing tcl list to args of an external program
- From: Anon432 Vqfz
- passing tcl list to args of an external program
- Prev by Date: Re: Using a tcl interpreter inside a DLL?
- Next by Date: Re: need help
- Previous by thread: passing tcl list to args of an external program
- Next by thread: error with tktable and mac OS 10.3
- Index(es):
Relevant Pages
|