Ensure non-UTF8 compatibility of argfile arg

This commit is contained in:
Weihang Lo 2022-04-10 00:46:24 +08:00
parent 9155c0062b
commit 3f749f615b
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -413,10 +413,11 @@ impl ProcessBuilder {
.prefix("cargo-argfile.")
.tempfile()?;
let path = tmp.path().display();
let mut arg = OsString::from("@");
arg.push(tmp.path());
let mut cmd = self.build_command_without_args();
cmd.arg(format!("@{path}"));
log::debug!("created argfile at {path} for `{self}`");
cmd.arg(arg);
log::debug!("created argfile at {} for {self}", tmp.path().display());
let cap = self.get_args().map(|arg| arg.len() + 1).sum::<usize>();
let mut buf = Vec::with_capacity(cap);