-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.rs
More file actions
34 lines (29 loc) · 842 Bytes
/
main.rs
File metadata and controls
34 lines (29 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::{
env,
os::unix::process::CommandExt,
process::{self, Command},
};
fn main() {
let current = match env::current_dir() {
Ok(dir) => dir,
Err(err) => {
eprintln!("Failed to get current directory: {}", err);
process::exit(1);
}
};
for dir in current.ancestors() {
let candidate = dir.join("x.py");
if candidate.exists() {
let error = Command::new(&candidate)
.args(env::args().skip(1))
.current_dir(dir)
.exec();
eprintln!("Failed to invoke `{}`: {}", candidate.display(), error);
process::exit(1);
}
}
eprintln!(
"x.py not found. Please run inside of a checkout of `https://github.com/rust-lang/rust`."
);
process::exit(1);
}