Skip to content

Commit

Permalink
nice: set exit code for clap errors to 125
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed May 1, 2022
1 parent 20bbc9b commit ea8463f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/uu/nice/src/nice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::ptr;

use clap::{crate_version, Arg, Command};
use uucore::{
error::{set_exit_code, UResult, USimpleError, UUsageError},
error::{set_exit_code, UClapError, UResult, USimpleError, UUsageError},
format_usage,
};

Expand All @@ -35,7 +35,7 @@ const USAGE: &str = "{} [OPTIONS] [COMMAND [ARGS]]";

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

let mut niceness = unsafe {
nix::errno::Errno::clear();
Expand Down
5 changes: 5 additions & 0 deletions tests/by-util/test_nice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ fn test_command_where_command_takes_n_flag() {
.run()
.stdout_is("a");
}

#[test]
fn test_invalid_argument() {
new_ucmd!().arg("--invalid").fails().code_is(125);
}

0 comments on commit ea8463f

Please sign in to comment.