Reputation: 4515
I have the following line in a TCL script...
exec {*}$cmd
I understand that exec
will run the command specified in the string $cmd
, but cant find any reference to what the {*}
does.... Can anyone tell me what the {*}
does please?
I've thought that the {...}
means that the first item is a group with no substitution allowed, so would it be like prefixing the string in $cmd
with an asterisk... but this makes no sense to me... any ideas guys?
If I write
set cmd "ls"
puts {*}$cmd
I get
ls
So the asterisk is not being printed. Put anything else inside the braces and I get an error... possibly some really simple TCL syntax I'm not aware of but would appreciate a pointer
Upvotes: 2
Views: 937
Reputation: 71568
In Tcl, {*}
will enumerate the elements of a list.
For instance, consider:
set cmd {$out Stuff}
puts $cmd
# => $out Stuff
puts {*}$cmd
# => can not find channel named "$out"
It is documented here.
Basically, the above code is puts
-ing {$out Stuff}
in the first case, but it is evaluating puts $out Stuff
in the second. Of course, if you now have a channel named $out
, you will have Stuff
in that channel.
Upvotes: 3