mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
Merge pull request #8135 from willshuttleworth/stty-set-undefined
stty: fix mappings with empty string literal args
This commit is contained in:
parent
6023888363
commit
01ac6dfd18
2 changed files with 37 additions and 3 deletions
|
@ -598,7 +598,7 @@ fn apply_char_mapping(termios: &mut Termios, mapping: &(SpecialCharacterIndices,
|
|||
//
|
||||
// This function returns the ascii value of valid control chars, or ControlCharMappingError if invalid
|
||||
fn string_to_control_char(s: &str) -> Result<u8, ControlCharMappingError> {
|
||||
if s == "undef" || s == "^-" {
|
||||
if s == "undef" || s == "^-" || s.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ fn runs() {
|
|||
#[test]
|
||||
#[ignore = "Fails because cargo test does not run in a tty"]
|
||||
fn print_all() {
|
||||
let res = new_ucmd!().succeeds();
|
||||
let res = new_ucmd!().args(&["--all"]).succeeds();
|
||||
|
||||
// Random selection of flags to check for
|
||||
for flag in [
|
||||
"parenb", "parmrk", "ixany", "iuclc", "onlcr", "ofdel", "icanon", "noflsh",
|
||||
"parenb", "parmrk", "ixany", "onlcr", "ofdel", "icanon", "noflsh",
|
||||
] {
|
||||
res.stdout_contains(flag);
|
||||
}
|
||||
|
@ -167,3 +167,37 @@ fn invalid_baud_setting() {
|
|||
.fails()
|
||||
.stderr_contains("invalid ospeed '995'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Fails because cargo test does not run in a tty"]
|
||||
fn set_mapping() {
|
||||
new_ucmd!().args(&["intr", "'"]).succeeds();
|
||||
new_ucmd!()
|
||||
.args(&["--all"])
|
||||
.succeeds()
|
||||
.stdout_contains("intr = '");
|
||||
|
||||
new_ucmd!().args(&["intr", "undef"]).succeeds();
|
||||
new_ucmd!()
|
||||
.args(&["--all"])
|
||||
.succeeds()
|
||||
.stdout_contains("intr = <undef>");
|
||||
|
||||
new_ucmd!().args(&["intr", "^-"]).succeeds();
|
||||
new_ucmd!()
|
||||
.args(&["--all"])
|
||||
.succeeds()
|
||||
.stdout_contains("intr = <undef>");
|
||||
|
||||
new_ucmd!().args(&["intr", ""]).succeeds();
|
||||
new_ucmd!()
|
||||
.args(&["--all"])
|
||||
.succeeds()
|
||||
.stdout_contains("intr = <undef>");
|
||||
|
||||
new_ucmd!().args(&["intr", "^C"]).succeeds();
|
||||
new_ucmd!()
|
||||
.args(&["--all"])
|
||||
.succeeds()
|
||||
.stdout_contains("intr = ^C");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue