1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

factor: handle the '< .' arg

This commit is contained in:
Sylvestre Ledru 2024-01-05 20:55:54 +01:00
parent 22a7173305
commit 4f33a375cd
2 changed files with 17 additions and 3 deletions

View file

@ -73,9 +73,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let stdin = stdin(); let stdin = stdin();
let lines = stdin.lock().lines(); let lines = stdin.lock().lines();
for line in lines { for line in lines {
for number in line.unwrap().split_whitespace() { match line {
print_factors_str(number, &mut w, print_exponents) Ok(line) => {
.map_err_context(|| "write error".into())?; for number in line.split_whitespace() {
print_factors_str(number, &mut w, print_exponents)
.map_err_context(|| "write error".into())?;
}
}
Err(e) => {
set_exit_code(1);
show_error!("error reading input: {}", e);
return Ok(());
}
} }
} }
} }

View file

@ -1258,3 +1258,8 @@ const PRIMES50: &[u64] = &[
1125899906841623, 1125899906841623,
1125899906841613, 1125899906841613,
]; ];
#[test]
fn fails_on_directory() {
new_ucmd!().pipe_in(".").fails();
}