1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #1731 from jaggededgedjustice/seq-check-for-zero-step

Do not allow seq to run with an increment of zero
This commit is contained in:
Alex Lyon 2021-02-18 18:28:35 -08:00 committed by GitHub
commit 15eaaa9473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -133,6 +133,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
} else {
1.0
};
if increment == 0.0 {
show_error!("increment value: '{}'", &numbers[1][..]);
return 1;
}
let last = {
let slice = &numbers[numbers.len() - 1][..];
padding = cmp::max(padding, slice.find('.').unwrap_or_else(|| slice.len()));

View file

@ -40,3 +40,9 @@ fn test_equalize_widths() {
fn test_seq_wrong_arg() {
new_ucmd!().args(&["-w", "5", "10", "33", "32"]).fails();
}
#[test]
fn test_zero_step() {
new_ucmd!().args(&["10", "0", "32"]).fails();
}