简体   繁体   English

如何避免 std::process::Command 单引号 escaping

[英]How to avoid std::process::Command single quote escaping

I am trying to run an ffmpeg command with a complex filter in Rust, and the std::process::Command blocks me from executing it by escaping the singles quotes, required as is by ffmpeg.我正在尝试在 Rust 中运行一个带有复杂过滤器的 ffmpeg 命令,而std::process::Command阻止我通过 escaping 单引号执行它,这是 ffmpeg 所要求的。

use std::process::Command;

fn main() {
    let mut cmd = Command::new("ffmpeg");
    cmd.args([
        "-filter_complex",
        "[video_0]geq=lum='p(X,Y)'[video_0];",
    ]);
    println!("Running command {:?}", cmd);
    // Actual:
    // Running command "ffmpeg" "-filter_complex" "[video_0]geq=lum=\'p(X,Y)\'[video_0];"
    // Expected: 
    // Running command "ffmpeg" "-filter_complex" "[video_0]geq=lum='p(X,Y)'[video_0];"

}

How can I run this command so that the single quotes are not escaped?我如何运行此命令以便不转义单引号? Is this a bug from the Command implementation?这是 Command 实现的错误吗?

Command 's debug view just view the arguments in debug view and that includes escaping characters, but it will still work. Command的调试视图仅在调试视图中查看 arguments,其中包括 escaping 个字符,但它仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM