src/Pure/System/command_line.ML
author wenzelm
Sat, 08 Dec 2018 22:31:34 +0100
changeset 69429 dc5fbcb07c7b
parent 62923 3a122e1e352a
child 71631 3f02bc5a5a03
permissions -rw-r--r--
replaced "isabelle components_checksum" shell script by "isabelle build_components" in Scala, with more functionality; more robust Component.Archive name: avoid rm_tree accidents;

(*  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 =
  Thread_Attributes.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 exit rc end) ();

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

end;