Skip to content

Commit 5aae06f

Browse files
committed
Do not display a backtrace when exiting normally
Exiting normally here refers to the `Exit_with_status` exception. It is in particular triggered by `#quit;;` so we want to exit quietly in that case. Closes #398
1 parent c596ac7 commit 5aae06f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Unreleased
33

44
* Bump the compatibility to 4.08+ (#393 @emillon)
55
* Load `@toplevel_printer` annotated printers for functors (#378 @metavinek)
6+
* Do not display a backtrace when exiting normally (#399 #398 @emillon)
67

78
2.10.0 (2022-10-06)
89
------------------

src/lib/uTop_main.ml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1632,23 +1632,22 @@ let main_aux ~initial_env =
16321632
exit 0
16331633

16341634
let main_internal ~initial_env =
1635-
let exit_status = ref 2 in
16361635
try
16371636
main_aux ~initial_env
16381637
with exn ->
16391638
(match exn with
1639+
#if OCAML_VERSION >= (4,12,0)
1640+
| Compenv.Exit_with_status e -> exit e
1641+
#endif
16401642
| Unix.Unix_error (error, func, "") ->
16411643
Printf.eprintf "%s: %s: %s\n" app_name func (Unix.error_message error)
16421644
| Unix.Unix_error (error, func, arg) ->
16431645
Printf.eprintf "%s: %s(%S): %s\n" app_name func arg (Unix.error_message error)
1644-
#if OCAML_VERSION >= (4,12,0)
1645-
| Compenv.Exit_with_status e -> exit_status := e
1646-
#endif
16471646
| exn ->
16481647
Printf.eprintf "Fatal error: exception %s\n" (Printexc.to_string exn));
16491648
Printexc.print_backtrace stderr;
16501649
flush stderr;
1651-
exit !exit_status
1650+
exit 2
16521651

16531652
let main () = main_internal ~initial_env:None
16541653

0 commit comments

Comments
 (0)