if I specify a -timeout N on an expect (to override the global timeout) then the timeout condition is not executed. It does properly timeout.
running version 5.43.0 on Linux
David T Kerns
demonstrates bug on *nix OS
Hm. I actually see the bug with an 5.43 build on linux as well ...
It is apparently not the -timeout 1 per se, but the fact that its presence prevents the interpretation of the argument after it as pattern/action list. It seems to be interpreted as a plain pattern with an empty action.
Continuing the investigation ...
I have now gone back to 5._41_.0 (Jun 7, 2004) and it exhibits the proclaimed bug. I am on linux. I would like to know where the 5.43 comes from which doesn't have the bug, as I wonder if the vendor applied local patches and fixes.
It is definitely the command line processing which recognizes a single pattern/action list argument as such if and only if it is (a) the one and only argument of the 'expect' command, or (b) it is preceded by a '-brace' flag, and flag + list are the sole two arguments of the 'expect' command. The moment additional flags are provided the pattern/action list is treated as pattern argument. And as the last argument it has no action.
The sources as far back as Jun 7, 2004 bear this out.
This long-evity of the behavior, plus the documentation I am not fully convinced that what you see is a bug. The way the documentation (*) is written I would actually expect (sic) the '-timeout 1' arguments to be either inside of the pattern/action list (**), not outside, or to have everything as separate arguments.
And indeed, when doing either the 'expect' command uses the local timeout. I am getting convinced that the bug is in pseudo-bad syntax of the invokation, not the expect package. Pseudo-bad because expect has a proper interpretation for the argument, just not the one you expected.
(**) " expect [[-opts] pat1 body1] ... [-opts] patn [bodyn] "
Another issue, the text '# expect this line' is NOT a comment, but the patterns '#' and 'this' with actions 'expect' and 'line'. Well, when the argument is recognized as pattern/action list.
My revision of tt with report of version and location of loaded package, and the confusing date info replaced by fixed strings.
Revised script demonstrating one form of correct syntax (everything as separate arguments)
Revised script demonstrating the second form of correct syntax (the options in the pattern list)