Skip to content

Commit 732d9b2

Browse files
committed
Return 0 when ./x.py has no subcommand
1 parent 2f5ae25 commit 732d9b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bootstrap/flags.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
136136
let subcommand = match subcommand {
137137
Some(s) => s,
138138
None => {
139-
// No subcommand -- show the general usage and subcommand help
139+
// No or an invalid subcommand -- show the general usage and subcommand help
140+
// An exit code will be 0 when no subcommand is given, and 1 in case of an invalid
141+
// subcommand.
140142
println!("{}\n", subcommand_help);
141-
process::exit(1);
143+
let exit_code = if args.is_empty() { 0 } else { 1 };
144+
process::exit(exit_code);
142145
}
143146
};
144147

0 commit comments

Comments
 (0)