1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Support legacy argument syntax for nice

This introduces an argument preprocessing step for the nice tool in
order to support the legacy nice adjustment syntax (`nice -1 foo`,
`nice --1 foo`, `nice -+1 foo` and so forth).

This is a preprocessing step because the interaction between these
arguments and the existing `nice -n -1` syntax becomes context
dependent, in a way that is currently difficult to capture through
clap.

Signed-off-by: Ed Smith <ed.smith@collabora.com>
This commit is contained in:
Ed Smith 2023-01-12 15:42:06 +00:00 committed by Sylvestre Ledru
parent 8c137f5d7c
commit 8aa9f346ef
2 changed files with 101 additions and 1 deletions

View file

@ -63,3 +63,22 @@ fn test_command_where_command_takes_n_flag() {
fn test_invalid_argument() {
new_ucmd!().arg("--invalid").fails().code_is(125);
}
#[test]
fn test_bare_adjustment() {
new_ucmd!()
.args(&["-1", "echo", "-n", "a"])
.run()
.stdout_is("a");
}
#[test]
fn test_trailing_empty_adjustment() {
new_ucmd!()
.args(&["-n", "1", "-n"])
.fails()
.stderr_str()
.starts_with(
"error: The argument '--adjustment <adjustment>' requires a value but none was supplied",
);
}