mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
clean up fold, hashsum, kill
This commit is contained in:
parent
1ac4eb171e
commit
ded92dbca0
3 changed files with 4 additions and 6 deletions
|
@ -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) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue