src/Pure/System/command_line.ML
author wenzelm
Wed, 07 May 2014 12:59:15 +0200
changeset 56895 f058120aaad4
parent 56630 d06c44532706
child 62470 9037ed690e19
permissions -rw-r--r--
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;

(*  Title:      Pure/System/command_line.ML
    Author:     Makarius

Support for Isabelle/ML command line tools.
*)

signature COMMAND_LINE =
sig
  val tool: (unit -> int) -> unit
  val tool0: (unit -> unit) -> unit
end;

structure Command_Line: COMMAND_LINE =
struct

fun tool body =
  uninterruptible (fn restore_attributes => fn () =>
    let
      val rc =
        restore_attributes body () handle exn =>
          Exn.capture_exit 2 (fn () => (Runtime.exn_error_message exn; raise exn)) ();
    in if rc = 0 then () else exit rc end) ();

fun tool0 body = tool (fn () => (body (); 0));

end;