Skip to content

Commit faef2f9

Browse files
committed
---
yaml --- r: 65277 b: refs/heads/master c: d930b2c h: refs/heads/master i: 65275: 0aa27bb v: v3
1 parent 2a6504f commit faef2f9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0628c92540c467de03524fae7f7061065de2295c
2+
refs/heads/master: d930b2cafba3784e0a2dde608f2c6eddcc285a39
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/librust/rust.rc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ extern mod rustc;
3232
use core::prelude::*;
3333

3434
use core::run;
35+
use core::libc::exit;
3536

3637
enum ValidUsage {
37-
Valid, Invalid
38+
Valid(int), Invalid
3839
}
3940

4041
impl ValidUsage {
4142
fn is_valid(&self) -> bool {
4243
match *self {
43-
Valid => true,
44-
Invalid => false
44+
Valid(_) => true,
45+
Invalid => false
4546
}
4647
}
4748
}
@@ -144,7 +145,7 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
144145
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
145146
UsgCall(f) => f(),
146147
}
147-
Valid
148+
Valid(0)
148149
},
149150
None => Invalid
150151
}
@@ -162,8 +163,8 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
162163
let test_exec = Path(filename).filestem().unwrap() + "test~";
163164
invoke("rustc", &[~"--test", filename.to_owned(),
164165
~"-o", test_exec.to_owned()], rustc::main);
165-
run::run_program(~"./" + test_exec, []);
166-
Valid
166+
let exit_code = run::run_program(~"./" + test_exec, []);
167+
Valid(exit_code)
167168
}
168169
_ => Invalid
169170
}
@@ -175,8 +176,8 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
175176
let exec = Path(filename).filestem().unwrap() + "~";
176177
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
177178
rustc::main);
178-
run::run_program(~"./"+exec, prog_args);
179-
Valid
179+
let exit_code = run::run_program(~"./"+exec, prog_args);
180+
Valid(exit_code)
180181
}
181182
_ => Invalid
182183
}
@@ -194,7 +195,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
194195
Call(f) => f(args),
195196
CallMain(prog, f) => {
196197
invoke(prog, args, f);
197-
Valid
198+
Valid(0)
198199
}
199200
}
200201
}
@@ -233,7 +234,10 @@ pub fn main() {
233234
if !args.is_empty() {
234235
for find_cmd(*args.head()).each |command| {
235236
let result = do_command(command, args.tail());
236-
if result.is_valid() { return; }
237+
match result {
238+
Valid(exit_code) => unsafe { exit(exit_code.to_i32()) },
239+
_ => loop
240+
}
237241
}
238242
}
239243

0 commit comments

Comments
 (0)