如何将std::process::Command转换为命令行字符串?
例如:如何将std::process::Command转换为命令行字符串?,process,rust,command,Process,Rust,Command,例如: let mut com = std::process::Command::new("ProgramA"); com.env("ENV_1", "VALUE_1") .arg("-a") .arg("foo") .arg("-b") .arg("--argument=bar"); // Get the command line string somehow here. com.output().unwrap(); 这将生成一个进程,该进程使用与之相关
let mut com = std::process::Command::new("ProgramA");
com.env("ENV_1", "VALUE_1")
.arg("-a")
.arg("foo")
.arg("-b")
.arg("--argument=bar");
// Get the command line string somehow here.
com.output().unwrap();
这将生成一个进程,该进程使用与之相关联的命令行““ProgramA”-a foo-b”-argument=和空格“”
有没有办法从
com
对象中获取此信息?结果是命令执行调试
;这将给我期望的结果:
let answer = format!("{:?}", com);