From 732d9b281cbcc88a627fddb660a3b4021e1d94cf Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 26 Oct 2017 06:03:07 +0900 Subject: [PATCH] Return 0 when ./x.py has no subcommand --- src/bootstrap/flags.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index df378188b4ad0..b5d51598fab88 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -136,9 +136,12 @@ To learn more about a subcommand, run `./x.py -h`"); let subcommand = match subcommand { Some(s) => s, None => { - // No subcommand -- show the general usage and subcommand help + // No or an invalid subcommand -- show the general usage and subcommand help + // An exit code will be 0 when no subcommand is given, and 1 in case of an invalid + // subcommand. println!("{}\n", subcommand_help); - process::exit(1); + let exit_code = if args.is_empty() { 0 } else { 1 }; + process::exit(exit_code); } };