Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
wstat += wstat_update;
match alarm.get_trigger() {
ALARM_TRIGGER_NONE => {}
t @ ALARM_TRIGGER_TIMER | t @ ALARM_TRIGGER_SIGNAL => {
t @ (ALARM_TRIGGER_TIMER | ALARM_TRIGGER_SIGNAL) => {
let tp = match t {
ALARM_TRIGGER_TIMER => ProgUpdateType::Periodic,
_ => ProgUpdateType::Signal,
Expand Down
11 changes: 5 additions & 6 deletions src/uu/env/src/split_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ impl<'a> SplitIterator<'a> {
self.get_parser().get_peek_position(),
"Delimiter".into(),
)),
Some('_') | Some(NEW_LINE) => {
Some('_' | NEW_LINE) => {
self.skip_one()?;
Ok(())
}
Some(DOLLAR) | Some(BACKSLASH) | Some('#') | Some(SINGLE_QUOTES)
| Some(DOUBLE_QUOTES) => {
Some(DOLLAR | BACKSLASH | '#' | SINGLE_QUOTES | DOUBLE_QUOTES) => {
self.take_one()?;
self.state_unquoted()
}
Expand Down Expand Up @@ -240,7 +239,7 @@ impl<'a> SplitIterator<'a> {
self.push_word_to_words();
Err(EnvError::EnvReachedEnd)
}
Some(DOLLAR) | Some(BACKSLASH) | Some(SINGLE_QUOTES) | Some(DOUBLE_QUOTES) => {
Some(DOLLAR | BACKSLASH | SINGLE_QUOTES | DOUBLE_QUOTES) => {
self.take_one()?;
Ok(())
}
Expand Down Expand Up @@ -283,7 +282,7 @@ impl<'a> SplitIterator<'a> {
self.skip_one()?;
Ok(())
}
Some(SINGLE_QUOTES) | Some(BACKSLASH) => {
Some(SINGLE_QUOTES | BACKSLASH) => {
self.take_one()?;
Ok(())
}
Expand Down Expand Up @@ -336,7 +335,7 @@ impl<'a> SplitIterator<'a> {
self.skip_one()?;
Ok(())
}
Some(DOUBLE_QUOTES) | Some(DOLLAR) | Some(BACKSLASH) => {
Some(DOUBLE_QUOTES | DOLLAR | BACKSLASH) => {
self.take_one()?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/expr/src/syntax_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> {
// Empty repeating pattern
invalid_content_error = true;
}
(x, None) | (x, Some("")) => {
(x, None | Some("")) => {
if x.parse::<i16>().is_err() {
invalid_content_error = true;
}
Expand Down
45 changes: 16 additions & 29 deletions src/uu/more/src/more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,33 +347,25 @@ fn more(
kind: KeyEventKind::Release,
..
}) => continue,
Event::Key(KeyEvent {
code: KeyCode::Char('q'),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
})
| Event::Key(KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
}) => {
Event::Key(
KeyEvent {
code: KeyCode::Char('q'),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}
| KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
},
) => {
reset_term(stdout);
std::process::exit(0);
}
Event::Key(KeyEvent {
code: KeyCode::Down,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::PageDown,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::Char(' '),
code: KeyCode::Down | KeyCode::PageDown | KeyCode::Char(' '),
modifiers: KeyModifiers::NONE,
..
}) => {
Expand All @@ -384,12 +376,7 @@ fn more(
}
}
Event::Key(KeyEvent {
code: KeyCode::Up,
modifiers: KeyModifiers::NONE,
..
})
| Event::Key(KeyEvent {
code: KeyCode::PageUp,
code: KeyCode::Up | KeyCode::PageUp,
modifiers: KeyModifiers::NONE,
..
}) => {
Expand Down
25 changes: 11 additions & 14 deletions src/uu/numfmt/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,18 @@ fn parse_implicit_precision(s: &str) -> usize {

fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
match (s, u) {
(Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => {
match raw_suffix {
RawSuffix::K => Ok(i * 1e3),
RawSuffix::M => Ok(i * 1e6),
RawSuffix::G => Ok(i * 1e9),
RawSuffix::T => Ok(i * 1e12),
RawSuffix::P => Ok(i * 1e15),
RawSuffix::E => Ok(i * 1e18),
RawSuffix::Z => Ok(i * 1e21),
RawSuffix::Y => Ok(i * 1e24),
}
}
(Some((raw_suffix, false)), &Unit::Auto | &Unit::Si) => match raw_suffix {
RawSuffix::K => Ok(i * 1e3),
RawSuffix::M => Ok(i * 1e6),
RawSuffix::G => Ok(i * 1e9),
RawSuffix::T => Ok(i * 1e12),
RawSuffix::P => Ok(i * 1e15),
RawSuffix::E => Ok(i * 1e18),
RawSuffix::Z => Ok(i * 1e21),
RawSuffix::Y => Ok(i * 1e24),
},
(Some((raw_suffix, false)), &Unit::Iec(false))
| (Some((raw_suffix, true)), &Unit::Auto)
| (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix {
| (Some((raw_suffix, true)), &Unit::Auto | &Unit::Iec(true)) => match raw_suffix {
RawSuffix::K => Ok(i * IEC_BASES[1]),
RawSuffix::M => Ok(i * IEC_BASES[2]),
RawSuffix::G => Ok(i * IEC_BASES[3]),
Expand Down
5 changes: 1 addition & 4 deletions src/uu/sort/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,7 @@ impl Compare<MergeableFile> for FileComparator<'_> {

// Wait for the child to exit and check its exit code.
fn check_child_success(mut child: Child, program: &str) -> UResult<()> {
if matches!(
child.wait().map(|e| e.code()),
Ok(Some(0)) | Ok(None) | Err(_)
) {
if matches!(child.wait().map(|e| e.code()), Ok(Some(0) | None) | Err(_)) {
Ok(())
} else {
Err(SortError::CompressProgTerminatedAbnormally {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ fn get_leading_gen(input: &str) -> Range<usize> {

let first = char_indices.peek();

if matches!(first, Some((_, NEGATIVE) | (_, POSITIVE))) {
if matches!(first, Some((_, NEGATIVE | POSITIVE))) {
char_indices.next();
}

Expand Down
8 changes: 5 additions & 3 deletions src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,11 @@ impl Settings {
// As those are writing to stdout of `split` and cannot write to filter command child process
let kth_chunk = matches!(
result.strategy,
Strategy::Number(NumberType::KthBytes(_, _))
| Strategy::Number(NumberType::KthLines(_, _))
| Strategy::Number(NumberType::KthRoundRobin(_, _))
Strategy::Number(
NumberType::KthBytes(_, _)
| NumberType::KthLines(_, _)
| NumberType::KthRoundRobin(_, _)
)
);
if kth_chunk && result.filter.is_some() {
return Err(SettingsError::FilterWithKthChunkNumber);
Expand Down
10 changes: 4 additions & 6 deletions src/uu/tail/src/follow/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,10 @@ impl Observer {
let display_name = self.files.get(event_path).display_name.clone();

match event.kind {
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any | MetadataKind::WriteTime))

// | EventKind::Access(AccessKind::Close(AccessMode::Write))
| EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any)
| EventKind::Modify(ModifyKind::Data(DataChange::Any))
| EventKind::Modify(ModifyKind::Name(RenameMode::To)) => {
EventKind::Modify(ModifyKind::Metadata(MetadataKind::Any |
MetadataKind::WriteTime) | ModifyKind::Data(DataChange::Any) |
ModifyKind::Name(RenameMode::To)) |
EventKind::Create(CreateKind::File | CreateKind::Folder | CreateKind::Any) => {
if let Ok(new_md) = event_path.metadata() {

let is_tailable = new_md.is_tailable();
Expand Down
16 changes: 6 additions & 10 deletions src/uu/test/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ impl Symbol {
Self::Bang => OsString::from("!"),
Self::BoolOp(s)
| Self::Literal(s)
| Self::Op(Operator::String(s))
| Self::Op(Operator::Int(s))
| Self::Op(Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => s,
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => s,
Self::None => panic!(),
})
}
Expand All @@ -99,11 +96,10 @@ impl std::fmt::Display for Symbol {
Self::Bang => OsStr::new("!"),
Self::BoolOp(s)
| Self::Literal(s)
| Self::Op(Operator::String(s))
| Self::Op(Operator::Int(s))
| Self::Op(Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s))
| Self::UnaryOp(UnaryOperator::FiletestOp(s)) => OsStr::new(s),
| Self::Op(Operator::String(s) | Operator::Int(s) | Operator::File(s))
| Self::UnaryOp(UnaryOperator::StrlenOp(s) | UnaryOperator::FiletestOp(s)) => {
OsStr::new(s)
}
Self::None => OsStr::new("None"),
};
write!(f, "{}", s.quote())
Expand Down
4 changes: 2 additions & 2 deletions src/uu/tr/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl Sequence {
if translating
&& set2.iter().any(|&x| {
matches!(x, Self::Class(_))
&& !matches!(x, Self::Class(Class::Upper) | Self::Class(Class::Lower))
&& !matches!(x, Self::Class(Class::Upper | Class::Lower))
})
{
return Err(BadSequence::ClassExceptLowerUpperInSet2);
Expand Down Expand Up @@ -290,7 +290,7 @@ impl Sequence {
&& !truncate_set1_flag
&& matches!(
set2.last().copied(),
Some(Self::Class(Class::Upper)) | Some(Self::Class(Class::Lower))
Some(Self::Class(Class::Upper | Class::Lower))
)
{
return Err(BadSequence::Set1LongerSet2EndsInClass);
Expand Down
Loading