Skip to content

Commit f9cf7e9

Browse files
committed
more: Disable raw mode before exiting if a panic occurs
1 parent c439f81 commit f9cf7e9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/uu/more/src/more.rs

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use std::{
99
fs::File,
1010
io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write},
11+
panic::set_hook,
1112
path::Path,
1213
time::Duration,
1314
};
@@ -87,6 +88,12 @@ impl Options {
8788

8889
#[uucore::main]
8990
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
91+
// Disable raw mode before exiting if a panic occurs
92+
set_hook(Box::new(|panic_info| {
93+
terminal::disable_raw_mode().unwrap();
94+
panic!("{}", panic_info);
95+
}));
96+
9097
let matches = match uu_app().try_get_matches_from(args) {
9198
Ok(m) => m,
9299
Err(e) => return Err(e.into()),

0 commit comments

Comments
 (0)