How to exit sclang process if class cannot recompile?

Hi all

I ran into a rather simple looking but devious issue today. I want to run an sclang process for the sole purpose of checking whether it manages to recompile the class library.

I have a file called exit.scd which contains 0.exit - this leads to a correct exit code if I run sclang exit.scd with a class library that does compile. But if the class library does not compile, the process just hangs and waits. How can I make sclang exit if it cannot recompile the class lib?

That sounds like a bug actually – I can’t think of any good reason why command line sclang should not exit with an error code if the library fails to compile.

In any case, Integer:exit certainly won’t work if the library didn’t compile. The only way would be for the c++ backend to quit automatically.

hjh

No doubt it’s best solved in sclang itself, but if all else fails I guess you could make a helper program to observe the sclang process. If sclang dies within a certain time limit, all’s well and if not, the helper program can forcibly close (kill) the sclang process. If sclang closes itself, the helper program can return its return code, otherwise the helper program can return a non-zero exit code itself.

So this was bothering me as its something I thought I might like to do…

Here is a git commit that will make this work… you can now do…

sclang -c && echo "compiled" || echo "failed"

… where -c is attempt to compile.

Its a super small addition to the source. Does any one know if I should bother will a pull request? Its probably a little messy right now…

Just wondering though: is there any reason why this should not be the default behavior?

In an editor context, we might want to keep the sclang process and let the editor give the “recompile” signal upon user request. I’m not sure that “interpreter quit or stopped forcibly” is a good message to give the user for a library-compile failure.

For command-line usage (no editor specified), I think it should be default behavior to quit upon library compile failure.

So the auto-quit should be conditional on the editor command-line option.

hjh