The patch below adds an --error-exit option and uses it in the
makefile. This avoids replacing the compiler with something that
doesn't work at all due to compilation errors.
diff --git a/Makefile.am b/Makefile.am
index af5853d..51372ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,7 +104,7 @@ polytemp.txt: $(POLYIMPORT)
# This builds the compiler but does not update the files in the imports directory.
# It then builds a version of poly containing the new compiler.
compiler: all
- ./poly $(BOOTSTRAP_OPTIONS) < mlsource/BuildExport.sml
+ ./poly $(BOOTSTRAP_OPTIONS) --error-exit < mlsource/BuildExport.sml
$(MAKE)
reboot: compiler
diff --git a/basis/FinalPolyML.sml b/basis/FinalPolyML.sml
index 0480aba..651f573 100644
--- a/basis/FinalPolyML.sml
+++ b/basis/FinalPolyML.sml
@@ -250,6 +250,8 @@ local
if ! useMarkupInOutput then prettyPrintWithIDEMarkup(stream, lineWidth)
else PolyML.prettyPrint(stream, lineWidth)
+ val exitOnError = ref false
+
(* Top-level prompts. *)
val prompt1 = ref "> " and prompt2 = ref "# ";
@@ -706,7 +708,10 @@ local
fun handledLoop () : unit =
(
(* Process a single top-level command. *)
- readEvalPrint() handle _ => ();
+ readEvalPrint() handle _ =>
+ if !exitOnError
+ then OS.Process.exit OS.Process.failure
+ else ();
(* Exit if we've seen end-of-file or we're in the debugger
and we've run "continue". *)
if !endOfFile orelse exitLoop() then ()
@@ -873,6 +878,7 @@ local
(* Generate mark-up in IDE code when printing if the option has been given
on the command line. *)
useMarkupInOutput := List.exists(fn s => s = "--with-markup") (CommandLine.arguments());
+ exitOnError := List.exists(fn s => s = "--error-exit") (CommandLine.arguments());
topLevel false (globalNameSpace, fn _ => false)
)
end
diff --git a/basis/TopLevelPolyML.sml b/basis/TopLevelPolyML.sml
index 405d5ae..0a18243 100644
--- a/basis/TopLevelPolyML.sml
+++ b/basis/TopLevelPolyML.sml
@@ -1121,6 +1121,7 @@ in
print "--help Print this message and exit\n";
print "-q Suppress the start-up message\n";
print "--use FILE Executes 'use \"FILE\";' before the ML shell starts\n";
+ print "--error-exit Exit shell on unhandled exception\n";
print "--with-markup Include extra mark-up information when printing\n";
print "--ideprotocol Run the IDE communications protocol\n";
print "\nRun time system arguments:\n";