Skip to content

Commit cf1fb57

Browse files
committed
1 parent a9482f8 commit cf1fb57

5 files changed

Lines changed: 40 additions & 49 deletions

File tree

src/uu/cp/src/cp.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,8 @@ impl Options {
11341134
options::PRESERVE => {
11351135
attributes = attributes.union(&Attributes::parse_iter(val.into_iter())?);
11361136
}
1137-
options::NO_PRESERVE => {
1138-
if !val.is_empty() {
1139-
attributes = attributes.diff(&Attributes::parse_iter(val.into_iter())?);
1140-
}
1137+
options::NO_PRESERVE if !val.is_empty() => {
1138+
attributes = attributes.diff(&Attributes::parse_iter(val.into_iter())?);
11411139
}
11421140
_ => (),
11431141
}

src/uu/date/src/format_modifiers.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,9 @@ fn apply_modifiers(value: &str, parsed: &ParsedSpec<'_>) -> Result<String, Forma
379379
uppercase = true;
380380
swap_case = false; // ^ overrides #
381381
}
382-
'#' => {
383-
if !uppercase {
384-
// Only apply # if ^ hasn't been set
385-
swap_case = true;
386-
}
382+
'#' if !uppercase => {
383+
// Only apply # if ^ hasn't been set
384+
swap_case = true;
387385
}
388386
'+' => {
389387
force_sign = true;

src/uu/od/src/od.rs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -132,38 +132,35 @@ impl OdOptions {
132132

133133
let formats = parse_format_flags(args).map_err(|e| USimpleError::new(1, e))?;
134134

135-
let mut line_bytes = match matches.get_one::<String>(options::WIDTH) {
136-
None => 16,
137-
Some(s) => {
138-
if matches.value_source(options::WIDTH) == Some(ValueSource::CommandLine) {
139-
let width_display = option_display_name(args, options::WIDTH, Some('w'));
140-
let parsed = parse_number_of_bytes(s).map_err(|e| {
141-
USimpleError::new(1, format_error_message(&e, s, &width_display))
142-
})?;
143-
if parsed == 0 {
144-
return Err(USimpleError::new(
145-
1,
146-
translate!(
147-
"od-error-invalid-argument",
148-
"option" => width_display.clone(),
149-
"value" => s.quote()
150-
),
151-
));
152-
}
153-
usize::try_from(parsed).map_err(|_| {
154-
USimpleError::new(
155-
1,
156-
translate!(
157-
"od-error-argument-too-large",
158-
"option" => width_display.clone(),
159-
"value" => s.quote()
160-
),
161-
)
162-
})?
163-
} else {
164-
16
165-
}
135+
let mut line_bytes = if let (Some(s), Some(ValueSource::CommandLine)) = (
136+
matches.get_one::<String>(options::WIDTH),
137+
matches.value_source(options::WIDTH),
138+
) {
139+
let width_display = option_display_name(args, options::WIDTH, Some('w'));
140+
let parsed = parse_number_of_bytes(s)
141+
.map_err(|e| USimpleError::new(1, format_error_message(&e, s, &width_display)))?;
142+
if parsed == 0 {
143+
return Err(USimpleError::new(
144+
1,
145+
translate!(
146+
"od-error-invalid-argument",
147+
"option" => width_display.clone(),
148+
"value" => s.quote()
149+
),
150+
));
166151
}
152+
usize::try_from(parsed).map_err(|_| {
153+
USimpleError::new(
154+
1,
155+
translate!(
156+
"od-error-argument-too-large",
157+
"option" => width_display.clone(),
158+
"value" => s.quote()
159+
),
160+
)
161+
})?
162+
} else {
163+
16
167164
};
168165

169166
let min_bytes = formats.iter().fold(1, |max, next| {

src/uu/tail/src/follow/watch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl Observer {
439439
*/
440440
}
441441
}
442-
EventKind::Modify(ModifyKind::Name(RenameMode::Both)) => {
442+
EventKind::Modify(ModifyKind::Name(RenameMode::Both))
443443
/*
444444
NOTE: For `tail -f a`, keep tracking additions to b after `mv a b`
445445
(gnu/tests/tail-2/descriptor-vs-rename.sh)
@@ -457,7 +457,7 @@ impl Observer {
457457
TODO: [2022-05; jhscheer] add test for this bug
458458
*/
459459

460-
if self.follow_descriptor() {
460+
if self.follow_descriptor() => {
461461
let new_path = event.paths.last().unwrap();
462462
paths.push(new_path.clone());
463463

@@ -472,7 +472,6 @@ impl Observer {
472472
let _ = self.watcher_rx.as_mut().unwrap().unwatch(event_path);
473473
self.watcher_rx.as_mut().unwrap().watch_with_parent(new_path)?;
474474
}
475-
}
476475
_ => {}
477476
}
478477
Ok(paths)

src/uucore/src/lib/features/fs.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,11 @@ pub fn canonicalize<P: AsRef<Path>>(
435435
}
436436
result.pop();
437437
}
438-
Err(e) => {
439-
if miss_mode == MissingHandling::Existing
440-
|| (miss_mode == MissingHandling::Normal && !parts.is_empty())
441-
{
442-
return Err(e);
443-
}
438+
Err(e)
439+
if (miss_mode == MissingHandling::Existing
440+
|| (miss_mode == MissingHandling::Normal && !parts.is_empty())) =>
441+
{
442+
return Err(e);
444443
}
445444
_ => {}
446445
}

0 commit comments

Comments
 (0)