diff options
-rw-r--r-- | src/split.c | 2 | ||||
-rwxr-xr-x | tests/split/b-chunk.sh | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/split.c b/src/split.c index f9c99db43..9a0704c26 100644 --- a/src/split.c +++ b/src/split.c @@ -982,7 +982,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize, start = (k - 1) * (file_size / n); end = (k == n) ? file_size : k * (file_size / n); - if (initial_read != SIZE_MAX || start < initial_read) + if (start < initial_read) { memmove (buf, buf + start, initial_read - start); initial_read -= start; diff --git a/tests/split/b-chunk.sh b/tests/split/b-chunk.sh index 8475f9679..c6619a2c7 100755 --- a/tests/split/b-chunk.sh +++ b/tests/split/b-chunk.sh @@ -25,9 +25,14 @@ split -n 10 /dev/null || fail=1 test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 rm -f x?? +# When extracting K of N where N > file size +# no data is extracted, and no files are written +split -n 2/3 /dev/null || fail=1 +returns_ 1 stat x?? 2>/dev/null || fail=1 + # Ensure --elide-empty-files is honored split -e -n 10 /dev/null || fail=1 -stat x?? 2>/dev/null && fail=1 +returns_ 1 stat x?? 2>/dev/null || fail=1 printf '1\n2\n3\n4\n5\n' > input || framework_failure_ |