src/Pure/System/command_line.ML
author wenzelm
Tue, 19 Sep 2023 13:02:48 +0200
changeset 78671 66e7a3131fe3
parent 71656 3e121f999120
child 78673 90b12b919b5f
permissions -rw-r--r--
tuned --- avoid pointless indirection (see also a2df9de46060);

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

Support for Isabelle/ML command line tools.
*)

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

structure Command_Line: COMMAND_LINE =
struct

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

end;