Skip to content

Commit 06f02fa

Browse files
committed
Remove bash_command().
`Command` can redirect stdout/stderr to file with `Command`, without resorting to bash redirection, and `TimePasses` already does that. This commit changes `Eprintln` and `MonoItems` to do that as well, which means `bash_command` is no longer necessary.
1 parent e2ec11a commit 06f02fa

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

collector/src/rustc-fake.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,11 @@ fn main() {
324324
}
325325

326326
"Eprintln" => {
327-
let mut cmd = bash_command(tool, args, "2> eprintln");
327+
let mut cmd = Command::new(tool);
328328
determinism_env(&mut cmd);
329+
cmd.args(args).stderr(std::process::Stdio::from(
330+
std::fs::File::create("eprintln").unwrap(),
331+
));
329332

330333
assert!(cmd.status().expect("failed to spawn").success());
331334
}
@@ -359,8 +362,11 @@ fn main() {
359362
// Lazy item collection is the default (i.e., without this
360363
// option)
361364
args.push("-Zprint-mono-items=lazy".into());
362-
let mut cmd = bash_command(tool, args, "1> mono-items");
365+
let mut cmd = Command::new(tool);
363366
determinism_env(&mut cmd);
367+
cmd.args(args).stdout(std::process::Stdio::from(
368+
std::fs::File::create("mono-items").unwrap(),
369+
));
364370

365371
assert!(cmd.status().expect("failed to spawn").success());
366372
}
@@ -459,24 +465,6 @@ fn process_self_profile_output(prof_out_dir: PathBuf, args: &[OsString]) {
459465
}
460466
}
461467

462-
/// Run a command via bash, in order to redirect its output to a file.
463-
/// `redirect` should be something like "> out" or "2> out".
464-
fn bash_command(tool: OsString, args: Vec<OsString>, redirect: &str) -> Command {
465-
let mut bash_cmd = String::new();
466-
bash_cmd.push_str(&format!("{} ", tool.to_str().unwrap()));
467-
for arg in args {
468-
// Args with double quotes (e.g. `--cfg feature="foo"`)
469-
// will be munged by bash if we don't protect them. So we
470-
// wrap every arg in single quotes.
471-
bash_cmd.push_str(&format!("'{}' ", arg.to_str().unwrap()));
472-
}
473-
bash_cmd.push_str(redirect);
474-
475-
let mut cmd = Command::new("bash");
476-
cmd.args(&["-c", &bash_cmd]);
477-
cmd
478-
}
479-
480468
#[cfg(windows)]
481469
fn exec(cmd: &mut Command) {
482470
let cmd_d = format!("{:?}", cmd);

0 commit comments

Comments
 (0)