<p>I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then it times out but does NOT print the 'timed out at step 2' I just get a new prompt.</p>

<p>Ideas?</p>

<pre><code>#!/usr/bin/expect --

spawn $env(SHELL)
match_max 100000

set timeout 2

send "echo This will print timed out\r"
expect  {
    timeout { puts "timed out at step 1"  }
    "foo " { puts "it said foo at step 1"}
}

puts "Starting test two\r"

send "echo This will not print timed out\r"
expect  -re {
    timeout { puts "timed out at step 2" ; exit }
    "foo " { puts "it said foo at step 2"}
}
</code></pre>

This
should
doesn't work in C++
since
even though it supports
short circuiting evaluation
.
Maybe
Don't try the following:
```
```
if ((CThing* pThing = GetThing()) && (pThing->IsReallySomeThing()))
{
}
```
```
err.. see
Wesley Tarle's answer