From 523e25df175bdee06d49927571f67cf3706473ac Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 23 Apr 2026 11:54:01 +0800 Subject: [PATCH] reader: fix improper use of get_or_init() --- src/reader/reader.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 2eedd5d7d..d7bd38996 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -1001,8 +1001,12 @@ pub fn reader_init(will_restore_foreground_pgroup: bool) { Err(_) => zeroed_termios(), }; - assert!(AT_EXIT.get().is_none()); - AT_EXIT.get_or_init(|| Box::new(move || reader_deinit(will_restore_foreground_pgroup))); + AT_EXIT + .set(Box::new(move || { + reader_deinit(will_restore_foreground_pgroup); + })) + .map_err(|_| ()) + .unwrap(); // Set the mode used for program execution, initialized to the current mode. let mut external_modes = terminal_mode_on_startup;