#65 Syntax errors in expect scripts yield an exit code of 0


Syntax errors in expect scripts yield an exit code of 0 (which is widely regarded as 'success' in makefiles and so on):

$ expect -c "this will fail"; echo "Exit code: $?"

invalid command name "this"
while executing
"this will fail"

Exit code: 0

I've written a quick-and-dirty tool that generates small expect scripts on the fly and runs them automatically.
If the tool happens to generate an invalid expect script, this problem will not be detected when script is run.
A non-zero exit code from expect would certainly help.

I've seen this problem with expect version 5.26 (the one that comes with Cygwin) and with version 5.43.0 (on debian 5.0).

I would also appreciate some "exit code" section in the man page describing where the exit code may come from
(and promising a non-zero exit code in case of error outside the user's script).
For example, I've also seen a non-zero exit code upon invalid command-line arguments:

$ expect -fail; echo "Exit code: $?"
couldn't read file "ail": no such file or directory
Exit code: 1

$ expect -abc; echo "Exit code: $?"
expect: unknown option -- a
usage: expect [-div] [-c cmds] [[-f] cmdfile] [args]
Exit code: 1


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks