I want to construct a complicate variable, let’s see :
set entry_arg [lindex $argv 1]
set command_to_launch {extrernal_command_tool -option "set var $entry_arg" -other_option}
exec $command_to_lauch
The command is launched, no problem …
but, the problem is that the tool get $entry_arg and crash … This is due to the ” ” that don’t allow tcl to interpret de variable
set command_to_launch {extrernal_command_tool -option "set var [lindex $argv 1]" -other_option}
Have the same problem !
How can I solve it ?
The problem isn’t
"", it’s{}. Try:You need to learn about interpolation, quoting and braces, like this: Understanding the usage of braces
(Also, I suspect you want to use
[lindex $argv 0]— TCL uses the variableargv0as the program name, and the arguments start at index 0, unlike C and other languages.)Edit:
You might actually mean this, if you really want a quoted argument like
"set var xxx":