tuned --- avoid pointless indirection (see also a2df9de46060);
authorwenzelm
Tue, 19 Sep 2023 13:02:48 +0200
changeset 78671 66e7a3131fe3
parent 78670 f8595f6d39a5
child 78672 fcdfd3251892
tuned --- avoid pointless indirection (see also a2df9de46060);
src/Pure/General/exn.ML
src/Pure/System/command_line.ML
--- a/src/Pure/General/exn.ML	Sun Sep 17 18:56:35 2023 +0100
+++ b/src/Pure/General/exn.ML	Tue Sep 19 13:02:48 2023 +0200
@@ -30,8 +30,6 @@
   val interrupt_exn: 'a result
   val is_interrupt_exn: 'a result -> bool
   val interruptible_capture: ('a -> 'b) -> 'a -> 'b result
-  val return_code: exn -> int -> int
-  val capture_exit: int -> ('a -> 'b) -> 'a -> 'b
   exception EXCEPTIONS of exn list
   val trace: (exn -> string) -> (string -> unit) -> (unit -> 'a) -> 'a
 end;
@@ -102,15 +100,6 @@
   Res (f x) handle e => if is_interrupt e then reraise e else Exn e;
 
 
-(* POSIX return code *)
-
-fun return_code exn rc =
-  if is_interrupt exn then 130 else rc;
-
-fun capture_exit rc f x =
-  f x handle exn => exit (return_code exn rc);
-
-
 (* concatenated exceptions *)
 
 exception EXCEPTIONS of exn list;
--- a/src/Pure/System/command_line.ML	Sun Sep 17 18:56:35 2023 +0100
+++ b/src/Pure/System/command_line.ML	Tue Sep 19 13:02:48 2023 +0200
@@ -15,9 +15,11 @@
 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 => Exn.capture_exit 2 (fn () => (Runtime.exn_error_message exn; raise exn)) ();
+        (restore_attributes body (); 0) handle exn =>
+          ((Runtime.exn_error_message exn; return_code exn) handle err => return_code err);
     in exit rc end) ();
 
 end;