From: Tim J. <tj...@to...> - 2005-03-24 19:35:30
|
Yep - my bad. The curly's are definitely needed. That's what I get for typing this stuff from memory without my morning coffee. Tim On Mar 24, 2005, at 12:17 PM, Michael Kirkham wrote: > On Thu, 24 Mar 2005, Kevin Walzer wrote: > >> I'm having a bit of trouble with the example you sent. When I use >> "catch," I'm getting errors whether the password is correct or not. >> Here's the test snippet I'm working with (substitute the right >> password >> for "right_password"): >> >> set password right_password >> >> if [catch [open "| echo $password | sudo -S ls /etc" {RDONLY}] >> err_text] { >> ~ tk_messageBox -message "$err_text" >> return >> } > > This really should be: > > if {[catch {open "| echo $password | sudo -S ls /etc" {RDONLY}} > err_text]} { > ... > > Without the braces, Tcl will do the substitution of [open] before > catch is invoked, and then it's going to catch attempting to execute > the file handle as a command, and then it's going to do double > substitution on the result of [catch] ... > > -- > Michael Kirkham > www.muonics.com > |