src/Pure/System/command_line.ML
changeset 48681 181b91e1d1c1
child 48731 a45ba78abcc1
equal deleted inserted replaced
48680:463daacae6c2 48681:181b91e1d1c1
       
     1 (*  Title:      Pure/System/command_line.ML
       
     2     Author:     Makarius
       
     3 
       
     4 Support for Isabelle/ML command line tools.
       
     5 *)
       
     6 
       
     7 signature COMMAND_LINE =
       
     8 sig
       
     9   val tool: (unit -> int) -> 'a
       
    10 end;
       
    11 
       
    12 structure Command_Line: COMMAND_LINE =
       
    13 struct
       
    14 
       
    15 fun tool body =
       
    16   uninterruptible (fn restore_attributes => fn () =>
       
    17     let val rc =
       
    18       restore_attributes body () handle exn =>
       
    19         (Output.error_msg (ML_Compiler.exn_message exn); if Exn.is_interrupt exn then 130 else 1);
       
    20     in exit rc; raise Fail "ERROR" end) ();
       
    21 
       
    22 end;
       
    23