Skip to content

Commit

Permalink
auto merge of #5863 : huonw/rust/rust-run-args, r=thestinger
Browse files Browse the repository at this point in the history
e.g. 
```
$ cat echo.rs
fn main() {
   io::println(fmt!("%?", os::args()));
}
$ rust run echo.rs 1 2 3
~[~"./echo~", ~"1", ~"2", ~"3"]
```
  • Loading branch information
bors committed Apr 13, 2013
2 parents 65ff441 + d70f0f1 commit d57aaae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librust/rust.rc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static commands: &'static [Command<'static>] = &[
usage_line: "build an executable, and run it",
usage_full: UsgStr(
"The run command is an shortcut for the command line \n\
\"rustc <filename> -o <filestem>~ && ./<filestem>~\".\
\n\nUsage:\trust run <filename>"
\"rustc <filename> -o <filestem>~ && ./<filestem>~ [<arguments>...]\".\
\n\nUsage:\trust run <filename> [<arguments>...]"
)
},
Command{
Expand Down Expand Up @@ -169,14 +169,14 @@ fn cmd_test(args: &[~str]) -> ValidUsage {

fn cmd_run(args: &[~str]) -> ValidUsage {
match args {
[filename] => {
[filename, ..prog_args] => {
let exec = Path(filename).filestem().unwrap() + "~";
if run::run_program("rustc", [
filename.to_owned(),
~"-o",
exec.to_owned()
]) == 0 {
run::run_program(~"./"+exec, []);
run::run_program(~"./"+exec, prog_args);
}
Valid
}
Expand Down

0 comments on commit d57aaae

Please sign in to comment.