mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #5914 from Ideflop/disable-row-mode-on-panic
more: Disable raw mode before exiting if a panic occurs
This commit is contained in:
commit
d53077160f
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write},
|
io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write},
|
||||||
|
panic::set_hook,
|
||||||
path::Path,
|
path::Path,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
@ -87,6 +88,13 @@ impl Options {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
// Disable raw mode before exiting if a panic occurs
|
||||||
|
set_hook(Box::new(|panic_info| {
|
||||||
|
terminal::disable_raw_mode().unwrap();
|
||||||
|
print!("\r");
|
||||||
|
println!("{panic_info}");
|
||||||
|
}));
|
||||||
|
|
||||||
let matches = match uu_app().try_get_matches_from(args) {
|
let matches = match uu_app().try_get_matches_from(args) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e.into()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue