Skip to content

Commit ec9fcb5

Browse files
authored
Merge pull request #8559 from julian-klode/stty-no-panic
Avoid panic in stty
2 parents 38a248c + a11c402 commit ec9fcb5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/uu/stty/src/stty.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ fn stty(opts: &Options) -> UResult<()> {
404404
}
405405

406406
// TODO: Figure out the right error message for when tcgetattr fails
407-
let mut termios = tcgetattr(opts.file.as_fd()).expect("Could not get terminal attributes");
407+
let mut termios = tcgetattr(opts.file.as_fd())?;
408408

409409
// iterate over valid_args, match on the arg type, do the matching apply function
410410
for arg in &valid_args {
@@ -419,12 +419,11 @@ fn stty(opts: &Options) -> UResult<()> {
419419
}
420420
}
421421
}
422-
tcsetattr(opts.file.as_fd(), set_arg, &termios)
423-
.expect("Could not write terminal attributes");
422+
tcsetattr(opts.file.as_fd(), set_arg, &termios)?;
424423
} else {
425424
// TODO: Figure out the right error message for when tcgetattr fails
426-
let termios = tcgetattr(opts.file.as_fd()).expect("Could not get terminal attributes");
427-
print_settings(&termios, opts).expect("TODO: make proper error here from nix error");
425+
let termios = tcgetattr(opts.file.as_fd())?;
426+
print_settings(&termios, opts)?;
428427
}
429428
Ok(())
430429
}

0 commit comments

Comments
 (0)