The easiest way is to do this:
proc myeval { args } { info_msg "Executing Tcl command: $args" set catch_res [catch $args res] if { $catch_res != 0 } { error_msg "Failed in command: $args" error_msg "$res" } return $res }
Here we have replaced catch {eval exec $args} res
with catch $args res
(plus some cosmetic stuff), which will make the arguments evaluate to script without further substitution. You would use it as follows:
myeval foo bar $boo
Alternatively, if you are doing substitutions in catch
, you should better write this more complex version:
proc myeval { script } { info_msg "Executing Tcl command: [string trim $script]" set catch_res [catch [list uplevel 1 $script] res] if { $catch_res != 0 } { error_msg "Failed in command: [string trim $script]" error_msg "$res" } return $res }
In this case, you would call it like this:
myeval { foo bar $boo }
source share