mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
stty: add min and time settings
This commit is contained in:
parent
ff11406c7a
commit
9e029f542b
2 changed files with 70 additions and 1 deletions
|
@ -319,6 +319,42 @@ fn stty(opts: &Options) -> UResult<()> {
|
|||
));
|
||||
}
|
||||
}
|
||||
} else if *arg == "min" {
|
||||
match args_iter.next() {
|
||||
Some(min) => match parse_u8_or_err(min) {
|
||||
Ok(n) => {
|
||||
valid_args
|
||||
.push(ArgOptions::Mapping((SpecialCharacterIndices::VMIN, n)));
|
||||
}
|
||||
Err(e) => return Err(USimpleError::new(1, e)),
|
||||
},
|
||||
None => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
get_message_with_args(
|
||||
"stty-error-missing-argument",
|
||||
HashMap::from([("arg".to_string(), arg.to_string())]),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
} else if *arg == "time" {
|
||||
match args_iter.next() {
|
||||
Some(time) => match parse_u8_or_err(time) {
|
||||
Ok(n) => valid_args
|
||||
.push(ArgOptions::Mapping((SpecialCharacterIndices::VTIME, n))),
|
||||
Err(e) => return Err(USimpleError::new(1, e)),
|
||||
},
|
||||
None => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
get_message_with_args(
|
||||
"stty-error-missing-argument",
|
||||
HashMap::from([("arg".to_string(), arg.to_string())]),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
// baud rate setting
|
||||
} else if let Some(baud_flag) = string_to_baud(arg) {
|
||||
valid_args.push(ArgOptions::Flags(baud_flag));
|
||||
|
|
|
@ -260,3 +260,36 @@ fn line() {
|
|||
.fails()
|
||||
.stderr_contains("invalid integer argument: '256'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn min_and_time() {
|
||||
new_ucmd!()
|
||||
.args(&["min"])
|
||||
.fails()
|
||||
.stderr_contains("missing argument to 'min'");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["time"])
|
||||
.fails()
|
||||
.stderr_contains("missing argument to 'time'");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["min", "-1"])
|
||||
.fails()
|
||||
.stderr_contains("invalid integer argument: '-1'");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["time", "-1"])
|
||||
.fails()
|
||||
.stderr_contains("invalid integer argument: '-1'");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["min", "256"])
|
||||
.fails()
|
||||
.stderr_contains("invalid integer argument: '256': Value too large for defined data type");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["time", "256"])
|
||||
.fails()
|
||||
.stderr_contains("invalid integer argument: '256': Value too large for defined data type");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue