rev: adapt error msg, replace match with let/else

This commit is contained in:
Daniel Hofstetter
2024-07-27 16:09:11 +02:00
parent 565f65c787
commit 04ccbe32ab

@ -20,17 +20,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match files { match files {
Some(files) => { Some(files) => {
for path in files { for path in files {
let file = match std::fs::File::open(path) { let Ok(file) = std::fs::File::open(path) else {
Ok(val) => val, uucore::error::set_exit_code(1);
Err(err) => { uucore::show_error!("cannot open {path}: No such file or directory");
uucore::error::set_exit_code(1); continue;
uucore::show_error!("cannot open {}: {}", path, err);
continue;
}
}; };
if let Err(err) = rev_stream(file) { if let Err(err) = rev_stream(file) {
uucore::error::set_exit_code(1); uucore::error::set_exit_code(1);
uucore::show_error!("cannot read {}: {}", path, err); uucore::show_error!("cannot read {path}: {err}");
} }
} }
} }