diff options
author | Canop <cano.petrole@gmail.com> | 2021-04-27 17:03:14 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-04-27 17:03:14 +0200 |
commit | 0e1ef761cd947bf537d84c3e2d5ae700d73a00ba (patch) | |
tree | f99332f0f3d7a0142c2131f51afe54e774b6467e /src/launchable.rs | |
parent | 76af65cc0baf8a541205a659774f281fec1b0a16 (diff) |
better handling of errors in launching external program non leaving
We were previously not correctly restoring broot's state on failed
external programs execution. It should be OK now.
Diffstat (limited to 'src/launchable.rs')
-rw-r--r-- | src/launchable.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/launchable.rs b/src/launchable.rs index a4096ae..b26e59f 100644 --- a/src/launchable.rs +++ b/src/launchable.rs @@ -153,14 +153,14 @@ impl Launchable { old_working_dir = std::env::current_dir().ok(); std::env::set_current_dir(working_dir).unwrap(); } - Command::new(&exe) + let exec_res = Command::new(&exe) .args(args.iter()) .spawn() .and_then(|mut p| p.wait()) .map_err(|source| ProgramError::LaunchError { program: exe.clone(), source, - })?; + }); if let Some(ref mut w) = &mut w { terminal::enable_raw_mode().unwrap(); if !mouse_capture_disabled { @@ -173,6 +173,7 @@ impl Launchable { if let Some(old_working_dir) = old_working_dir { std::env::set_current_dir(old_working_dir).unwrap(); } + exec_res?; // we trigger the error display after restoration Ok(()) } Launchable::SystemOpen { path } => { |