[plt-scheme] Is there a way to do this?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Sep 14 10:07:52 EDT 2008

At Sun, 14 Sep 2008 06:59:45 -0700 (PDT), "narutocanada at gmail.com" wrote:
> Is there a way to find out during the interpretation of a program that
> any error was encountered, either syntactical or run time error--
> currently mzscheme always return 0 at the shell level:
> cat any.sc | mzscheme ; echo $?
> # always 0
> Providing a user defined error function only catches certain error but
> not syntactical or other run time error-- like "identifier not found".
> I need a way to catch any error and exit with any value other then 0
> for batch processing large number of test files.

The exit status for `mzscheme' indicates an error if an error occurs
during a command-line eval (using -e, etc.), load (using -f, -r, etc.),
or require (using -l, etc.) when no read-eval-print loop is started.
Otherwise, the exit status is 0 or determined by a call to exit.

(That's from 16.1.1 in the PLT Scheme reference, but I edited it a
little to fill in some context.)

So you might just want

  mzscheme any.sc ; echo $?

If you really need to pipe expressions into the REPL, then you could
set `uncaught-exception-handler' to call `exit' with a non-0 value.


Posted on the users mailing list.