mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
clean up fold, hashsum, kill
This commit is contained in:
@@ -98,7 +98,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||||||
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
||||||
for (i, arg) in args.iter().enumerate() {
|
for (i, arg) in args.iter().enumerate() {
|
||||||
let slice = &arg;
|
let slice = &arg;
|
||||||
if slice.starts_with('-') && slice.len() > 1 && slice.chars().nth(1).unwrap().is_digit(10) {
|
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_digit(10)) {
|
||||||
let mut v = args.to_vec();
|
let mut v = args.to_vec();
|
||||||
v.remove(i);
|
v.remove(i);
|
||||||
return (v, Some(slice[1..].to_owned()));
|
return (v, Some(slice[1..].to_owned()));
|
||||||
|
|||||||
@@ -255,10 +255,8 @@ fn detect_algo<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if alg.is_none() {
|
let alg = alg.unwrap_or_else(|| crash!(1, "You must specify hash algorithm!"));
|
||||||
crash!(1, "You must specify hash algorithm!")
|
(name, alg, output_bits)
|
||||||
};
|
|
||||||
(name, alg.unwrap(), output_bits)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ fn handle_obsolete(mut args: Vec<String>) -> (Vec<String>, Option<String>) {
|
|||||||
while i < args.len() {
|
while i < args.len() {
|
||||||
// this is safe because slice is valid when it is referenced
|
// this is safe because slice is valid when it is referenced
|
||||||
let slice = &args[i].clone();
|
let slice = &args[i].clone();
|
||||||
if slice.starts_with('-') && slice.len() > 1 && slice.chars().nth(1).unwrap().is_digit(10) {
|
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_digit(10)) {
|
||||||
let val = &slice[1..];
|
let val = &slice[1..];
|
||||||
match val.parse() {
|
match val.parse() {
|
||||||
Ok(num) => {
|
Ok(num) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user