mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
stty: disallow combining settings with --all and --save
This commit is contained in:
parent
eac88022b2
commit
679fd2371e
1 changed files with 10 additions and 2 deletions
|
@ -85,7 +85,7 @@ mod options {
|
||||||
|
|
||||||
struct Options<'a> {
|
struct Options<'a> {
|
||||||
all: bool,
|
all: bool,
|
||||||
_save: bool,
|
save: bool,
|
||||||
file: RawFd,
|
file: RawFd,
|
||||||
settings: Option<Vec<&'a str>>,
|
settings: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ impl<'a> Options<'a> {
|
||||||
fn from(matches: &'a ArgMatches) -> io::Result<Self> {
|
fn from(matches: &'a ArgMatches) -> io::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
all: matches.is_present(options::ALL),
|
all: matches.is_present(options::ALL),
|
||||||
_save: matches.is_present(options::SAVE),
|
save: matches.is_present(options::SAVE),
|
||||||
file: match matches.value_of(options::FILE) {
|
file: match matches.value_of(options::FILE) {
|
||||||
Some(_f) => todo!(),
|
Some(_f) => todo!(),
|
||||||
None => stdout().as_raw_fd(),
|
None => stdout().as_raw_fd(),
|
||||||
|
@ -120,7 +120,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
fn stty(opts: &Options) -> UResult<()> {
|
fn stty(opts: &Options) -> UResult<()> {
|
||||||
// TODO: Figure out the right error message
|
// TODO: Figure out the right error message
|
||||||
let mut termios = tcgetattr(opts.file).expect("Could not get terminal attributes");
|
let mut termios = tcgetattr(opts.file).expect("Could not get terminal attributes");
|
||||||
|
|
||||||
if let Some(settings) = &opts.settings {
|
if let Some(settings) = &opts.settings {
|
||||||
|
if opts.save || opts.all {
|
||||||
|
return Err(USimpleError::new(
|
||||||
|
1,
|
||||||
|
"when specifying an output style, modes may not be set",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
for setting in settings {
|
for setting in settings {
|
||||||
if let ControlFlow::Break(false) = apply_setting(&mut termios, setting) {
|
if let ControlFlow::Break(false) = apply_setting(&mut termios, setting) {
|
||||||
return Err(USimpleError::new(
|
return Err(USimpleError::new(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue