|
1 |
| -extern crate libc; |
2 |
| - |
3 | 1 | use std::collections::BTreeMap;
|
4 | 2 | use std::collections::HashMap;
|
5 | 3 | use std::collections::HashSet;
|
6 | 4 | use std::env;
|
7 | 5 | use std::path::Path;
|
8 | 6 | use std::vec::IntoIter;
|
9 | 7 | use std::borrow::ToOwned;
|
| 8 | +use std::process; |
10 | 9 |
|
11 | 10 | use args::{ ArgMatches, Arg, SubCommand };
|
12 | 11 | use args::{FlagArg, FlagBuilder};
|
@@ -619,7 +618,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
619 | 618 | }
|
620 | 619 | }
|
621 | 620 |
|
622 |
| - self.exit(); |
| 621 | + self.exit(0); |
623 | 622 | }
|
624 | 623 |
|
625 | 624 | #[inline(always)]
|
@@ -657,17 +656,18 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
657 | 656 | // Print the binary name if existing, but replace all spaces with hyphens in case we're
|
658 | 657 | // dealing with subcommands i.e. git mv is translated to git-mv
|
659 | 658 | println!("{} {}", &self.bin_name.clone().unwrap_or(self.name.clone())[..].replace(" ", "-"), self.version.unwrap_or("") );
|
660 |
| - if quit { self.exit(); } |
| 659 | + if quit { self.exit(0); } |
661 | 660 | }
|
662 | 661 |
|
663 |
| - fn exit(&self) { |
664 |
| - unsafe { libc::exit(0); } |
| 662 | + fn exit(&self, status: i32) { |
| 663 | + process::exit(status); |
| 664 | + // unsafe { libc::exit(0); } |
665 | 665 | }
|
666 | 666 |
|
667 | 667 | fn report_error(&self, msg: String, usage: bool, quit: bool) {
|
668 | 668 | println!("{}", msg);
|
669 | 669 | if usage { self.print_usage(true); }
|
670 |
| - if quit { env::set_exit_status(1); self.exit(); } |
| 670 | + if quit { self.exit(1); } |
671 | 671 | }
|
672 | 672 |
|
673 | 673 | pub fn get_matches(mut self) -> ArgMatches<'ar> {
|
|
0 commit comments