【发布时间】:2018-04-19 19:15:30
【问题描述】:
compgen 命令在 Linux 终端中运行良好,但在使用 Command::new 时会导致崩溃。
我的代码:
use std::process::Command;
fn main() {
let status = Command::new("compgen")
.status()
.expect("failed to execute process");
println!("process exited with: {}", status);
}
错误信息:
Compiling terminal v0.1.0 (file:///home/user/programmates/RUST/Terminal/terminal)
Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs
Running `target/debug/terminal`
thread 'main' panicked at 'failed to execute process: Os { code: 2, kind: NotFound, message: "No such file or directory" }', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
【问题讨论】:
-
这是一个内置的shell而不是可执行文件,所以你需要调用shell。