mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix positional arguments in shell command on Windows
This commit is contained in:
parent
b48edfd764
commit
c174b01b8f
3 changed files with 29 additions and 12 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -325,6 +325,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmdexpand"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ndtoan96/cmdexpand.git?tag=v0.1.0#be905e223c7ed5f52655fb4096c842f2f587f0d7"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
|
|
@ -374,6 +383,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"async-channel",
|
||||
"clipboard-win",
|
||||
"cmdexpand",
|
||||
"config",
|
||||
"crossterm",
|
||||
"futures",
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ yazi-prebuild = "^0"
|
|||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
clipboard-win = "^4"
|
||||
cmdexpand = {git = "https://github.com/ndtoan96/cmdexpand.git", tag = "v0.1.0"}
|
||||
|
||||
[target.'cfg(not(target_os = "netbsd"))'.dependencies]
|
||||
trash = "^3"
|
||||
|
|
|
|||
30
core/src/external/shell.rs
vendored
30
core/src/external/shell.rs
vendored
|
|
@ -43,16 +43,22 @@ pub fn shell(opt: ShellOpt) -> Result<Child> {
|
|||
.spawn()?,
|
||||
);
|
||||
|
||||
#[cfg(windows)]
|
||||
return Ok(
|
||||
Command::new("cmd")
|
||||
.stdin(opt.stdio())
|
||||
.stdout(opt.stdio())
|
||||
.stderr(opt.stdio())
|
||||
.arg("/C")
|
||||
.arg(opt.cmd)
|
||||
.args(opt.args)
|
||||
.kill_on_drop(true)
|
||||
.spawn()?,
|
||||
);
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let args: Vec<String> = opt.args.iter().map(|s| s.to_string_lossy().to_string()).collect();
|
||||
let cmd = cmdexpand::Expander::new(&opt.cmd.to_string_lossy().to_string())
|
||||
.disable_context(true)
|
||||
.add_args(&args)
|
||||
.expand()?;
|
||||
Ok(
|
||||
Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg(cmd)
|
||||
.stdin(if opt.piped { Stdio::piped() } else { Stdio::inherit() })
|
||||
.stdout(if opt.piped { Stdio::piped() } else { Stdio::inherit() })
|
||||
.stderr(if opt.piped { Stdio::piped() } else { Stdio::inherit() })
|
||||
.kill_on_drop(true)
|
||||
.spawn()?,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue