← All bug reports

FS#483Return value of autostart applications

Type
Bug
Status
Closed
Resolution
Fixed
Category
QCAD (main)
Severity
Low
Priority
Low
Reported version
3 RC3
Operating system
All
Reported
2012-02-03 by hungerburg
Closed
2012-02-03 by andrew

Whe qcad runs a script from the autostart command line argument, then, if this script ends with an error, the qcad main function should not return 0, but something different, because the return value of 0 is conventionally used to indicate successful operation.

I enter this as a bug, rather than a feature request, because this convention is so entrained (at least in *NIX land), that it breaks fundamental expecations on application behaviour.

Comments (5)

andrew 2012-02-03

Please define in more detail the part "if this script ends with an error". Does this mean a script exception is hit or a logical error (e.g. the script cannot find a file or the user given command line arguments are wrong, etc)?

andrew 2012-02-03

Also: Can the return value be defined by the script? If so, how?

TODO: Find out how other script interpreters handle that situation (e.g. Python).

hungerburg 2012-02-03

Dear Andrew, by "end with an error" I think of eg. exceptions in the ECMA interpreter, that are not caught in the script, things that bring up the debugger or have qcad -no-gui print a stack trace. They happen eventually to the best of programmers and qcad already knows of them.

To let the script itself define a return value was a nice feature. But for a start, a script could always just "throw" something and the consumer can parse the language. The need of integer return values other than 0=OK, 1=fail should post a use case first, not?

Thank You

Peter

hungerburg 2012-02-03

The rhino javascript interpreter has a "quit()" command, that takes an integer argument. Maybe qt ecma has that too?

andrew 2012-02-03

Qt indeed has QCoreApplication.exit(integerExitCode); but that exit code does not seem to make it to the caller. Not sure why.

An exit code of 1 if there are uncaught exceptions is certainly possible.

Closure comment

r20432