src/Pure/System/command_line.ML
author wenzelm
Mon, 30 Mar 2020 19:50:01 +0200
changeset 71632 c1bc38327bc2
parent 71631 3f02bc5a5a03
child 71656 3e121f999120
permissions -rw-r--r--
clarified signature;

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

Support for Isabelle/ML command line tools.
*)

signature COMMAND_LINE =
sig
  exception EXIT of int
  val tool: (unit -> unit) -> unit
end;

structure Command_Line: COMMAND_LINE =
struct

exception EXIT of int;

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

end;