Remove quotes from external args (#5846)

* remove quotes from external args

* remove internal quotes

* correct escaped quotes in string
This commit is contained in:
Fernando Herrera 2022-06-22 22:01:44 -05:00 committed by GitHub
parent 3c0bccb900
commit f231a6df4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -411,7 +411,7 @@ impl ExternalCommand {
for arg in self.args.iter() {
let mut arg = Spanned {
item: trim_enclosing_quotes(&arg.item),
item: remove_quotes(trim_enclosing_quotes(&arg.item)),
span: arg.span,
};
@ -527,6 +527,19 @@ fn trim_enclosing_quotes(input: &str) -> String {
}
}
fn remove_quotes(input: String) -> String {
let mut chars = input.chars();
match chars.next_back() {
Some('"') => chars
.collect::<String>()
.replacen('"', "", 1)
.replace(r#"\""#, "\""),
Some('\'') => chars.collect::<String>().replacen('\'', "", 1),
_ => input,
}
}
// Receiver used for the RawStream
// It implements iterator so it can be used as a RawStream
struct ChannelReceiver {