src/Pure/System/command_line.ML
author wenzelm
Sun Aug 05 13:42:21 2012 +0200 (2012-08-05 ago)
changeset 48681 181b91e1d1c1
child 48731 a45ba78abcc1
permissions -rw-r--r--
prefer general Command_Line.tool wrapper (cf. Scala version);
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@48681
     9
  val tool: (unit -> int) -> 'a
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@48681
    20
    in exit rc; raise Fail "ERROR" end) ();
wenzelm@48681
    21
wenzelm@48681
    22
end;
wenzelm@48681
    23