From bdcf7941c784703cbe8744c2faf59b4a1d819afd Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 16 Jan 2024 00:24:25 +0800 Subject: [PATCH] Also add for Windows --- yazi-plugin/src/external/shell.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yazi-plugin/src/external/shell.rs b/yazi-plugin/src/external/shell.rs index f3908795..fe9fc9c2 100644 --- a/yazi-plugin/src/external/shell.rs +++ b/yazi-plugin/src/external/shell.rs @@ -29,18 +29,12 @@ impl ShellOpt { } pub fn shell(opt: ShellOpt) -> Result { + let level = env::var("YAZI_LEVEL").ok().and_then(|s| s.parse::().ok()).unwrap_or(0); + #[cfg(unix)] return Ok(unsafe { Command::new("sh") - .env( - "YAZI_LEVEL", - (env::var("YAZI_LEVEL") - .ok() - .and_then(|lvl_str| lvl_str.parse::().ok()) - .unwrap_or(0) - + 1) - .to_string(), - ) + .env("YAZI_LEVEL", (level + 1).to_string()) .arg("-c") .stdin(opt.stdio()) .stdout(opt.stdio()) @@ -65,6 +59,7 @@ pub fn shell(opt: ShellOpt) -> Result { let expanded = parser::parse(opt.cmd.to_string_lossy().as_ref(), &args_); Ok( Command::new("cmd") + .env("YAZI_LEVEL", (level + 1).to_string()) .arg("/C") .args(&expanded) .stdin(opt.stdio())