Skip to content

Commit d530771

Browse files
authored
Merge pull request #5914 from Ideflop/disable-row-mode-on-panic
more: Disable raw mode before exiting if a panic occurs
2 parents a5fc9af + b9112da commit d530771

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/uu/more/src/more.rs

+8
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,13 @@ 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+
print!("\r");
95+
println!("{panic_info}");
96+
}));
97+
9098
let matches = match uu_app().try_get_matches_from(args) {
9199
Ok(m) => m,
92100
Err(e) => return Err(e.into()),

0 commit comments

Comments
 (0)