Skip to content

Commit e40f175

Browse files
authored
Merge pull request #3922 from tertsdiepraam/fix-usage-exit-codes
all: change remaining usage codes of 2 to 1 for GNU compat
2 parents 70714bc + 9177cb7 commit e40f175

File tree

148 files changed

+492
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+492
-99
lines changed

src/uu/arch/src/arch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static SUMMARY: &str = "Determine architecture name for current machine.";
1616

1717
#[uucore::main]
1818
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
19-
uu_app().get_matches_from(args);
19+
uu_app().try_get_matches_from(args)?;
2020

2121
let uts = PlatformInfo::new().map_err_context(|| "cannot get system name".to_string())?;
2222
println!("{}", uts.machine().trim());

src/uu/basename/src/basename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
4949
//
5050
// Argument parsing
5151
//
52-
let matches = uu_app().get_matches_from(args);
52+
let matches = uu_app().try_get_matches_from(args)?;
5353

5454
// too few arguments
5555
if !matches.contains_id(options::NAME) {

src/uu/chmod/src/chmod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
5454

5555
let after_help = get_long_usage();
5656

57-
let matches = uu_app().after_help(&after_help[..]).get_matches_from(args);
57+
let matches = uu_app()
58+
.after_help(&after_help[..])
59+
.try_get_matches_from(args)?;
5860

5961
let changes = matches.contains_id(options::CHANGES);
6062
let quiet = matches.contains_id(options::QUIET);

src/uu/chroot/src/chroot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ffi::CString;
1515
use std::io::Error;
1616
use std::path::Path;
1717
use std::process;
18-
use uucore::error::{set_exit_code, UResult};
18+
use uucore::error::{set_exit_code, UClapError, UResult};
1919
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
2020
use uucore::{entries, format_usage};
2121

@@ -35,7 +35,7 @@ mod options {
3535
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
3636
let args = args.collect_lossy();
3737

38-
let matches = uu_app().get_matches_from(args);
38+
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
3939

4040
let default_shell: &'static str = "/bin/sh";
4141
let default_option: &'static str = "-i";

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mod options {
115115
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
116116
let args = args.collect_ignore();
117117

118-
let matches = uu_app().get_matches_from(args);
118+
let matches = uu_app().try_get_matches_from(args)?;
119119

120120
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {
121121
Some(v) => v.clone().map(|v| v.to_owned()).collect(),

src/uu/comm/src/comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
134134
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
135135
let args = args.collect_lossy();
136136

137-
let matches = uu_app().get_matches_from(args);
137+
let matches = uu_app().try_get_matches_from(args)?;
138138
let filename1 = matches.value_of(options::FILE_1).unwrap();
139139
let filename2 = matches.value_of(options::FILE_2).unwrap();
140140
let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?;

src/uu/csplit/src/csplit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ mod tests {
715715
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
716716
let args = args.collect_ignore();
717717

718-
let matches = uu_app().get_matches_from(args);
718+
let matches = uu_app().try_get_matches_from(args)?;
719719

720720
// get the file to split
721721
let file_name = matches.value_of(options::FILE).unwrap();

src/uu/cut/src/cut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
401401
let args = args.collect_ignore();
402402

403403
let delimiter_is_equal = args.contains(&"-d=".to_string()); // special case
404-
let matches = uu_app().get_matches_from(args);
404+
let matches = uu_app().try_get_matches_from(args)?;
405405

406406
let complement = matches.contains_id(options::COMPLEMENT);
407407

src/uu/date/src/date.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'a> From<&'a str> for Rfc3339Format {
144144

145145
#[uucore::main]
146146
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
147-
let matches = uu_app().get_matches_from(args);
147+
let matches = uu_app().try_get_matches_from(args)?;
148148

149149
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
150150
if !form.starts_with('+') {

src/uu/dd/src/dd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
712712

713713
let matches = uu_app()
714714
//.after_help(TODO: Add note about multiplier strings here.)
715-
.get_matches_from(dashed_args);
715+
.try_get_matches_from(dashed_args)?;
716716

717717
match (
718718
matches.contains_id(options::INFILE),

0 commit comments

Comments
 (0)