test: minimal shell quote supoort for cargo-test-support

This commit is contained in:
Weihang Lo 2020-10-04 22:55:50 +08:00
parent 1f6c6bd5e7
commit be31989a43
No known key found for this signature in database
GPG key ID: D7DBF189825E82E7

View file

@ -1637,8 +1637,12 @@ impl ChannelChanger for cargo::util::ProcessBuilder {
}
fn split_and_add_args(p: &mut ProcessBuilder, s: &str) {
for arg in s.split_whitespace() {
if arg.contains('"') || arg.contains('\'') {
for mut arg in s.split_whitespace() {
if (arg.starts_with('"') && arg.ends_with('"'))
|| (arg.starts_with('\'') && arg.ends_with('\''))
{
arg = &arg[1..(arg.len() - 1).max(1)];
} else if arg.contains(&['"', '\''][..]) {
panic!("shell-style argument parsing is not supported")
}
p.arg(arg);