src/Pure/System/command_line.ML
author wenzelm
Wed Aug 08 12:33:40 2012 +0200 (2012-08-08 ago)
changeset 48731 a45ba78abcc1
parent 48681 181b91e1d1c1
child 51312 0ce544fbb509
permissions -rw-r--r--
more casual exit back to ML toplevel, to accomodate commit in SML/NJ which continues at the saved point;
wenzelm@48681
     1
(*  Title:      Pure/System/command_line.ML
wenzelm@48681
     2
    Author:     Makarius
wenzelm@48681
     3
wenzelm@48681
     4
Support for Isabelle/ML command line tools.
wenzelm@48681
     5
*)
wenzelm@48681
     6
wenzelm@48681
     7
signature COMMAND_LINE =
wenzelm@48681
     8
sig
wenzelm@48731
     9
  val tool: (unit -> int) -> unit
wenzelm@48681
    10
end;
wenzelm@48681
    11
wenzelm@48681
    12
structure Command_Line: COMMAND_LINE =
wenzelm@48681
    13
struct
wenzelm@48681
    14
wenzelm@48681
    15
fun tool body =
wenzelm@48681
    16
  uninterruptible (fn restore_attributes => fn () =>
wenzelm@48681
    17
    let val rc =
wenzelm@48681
    18
      restore_attributes body () handle exn =>
wenzelm@48681
    19
        (Output.error_msg (ML_Compiler.exn_message exn); if Exn.is_interrupt exn then 130 else 1);
wenzelm@48731
    20
    in if rc = 0 then () else exit rc end) ();
wenzelm@48681
    21
wenzelm@48681
    22
end;
wenzelm@48681
    23