Reputation: 1177
I am very new to Expect/TCL and just wanted to confirm that in the example below, the curly-braces just work as single-quotes in bash to group the body of the expect
command? Example:
expect {
-re "(P|p)assword: " { send "$pwd\r" }
-re "Connection timed out" { puts "Timeout error"; exit 1 }
-re "Connection closed" { puts "Host error"; exit 1 }
timeout { puts "Timeout error"; exit 1 }
eof { puts "Connection error"; exit 1 }
}
Upvotes: 0
Views: 1619
Reputation: 137567
In standard Tcl, that's exactly how braces work. (OK, lots of command implementations then use the quoted thing immediately, but everything works pretty much as you'd expect.)
However, you're looking at the body of an expect
command. The outer braces (on the first and last line) are the ones that are guaranteed to work that way; the others are up to the expect
command — implemented in C — to interpret as it chooses. The documentation states that if the contents of the braces are multiline, they're interpreted as a (Tcl) list, which makes them work in pretty much the way you're after. (As Tcl commands go, that's deeply strange, but Expect has worked that way for decades now so it isn't about to change.)
Upvotes: 1