Subject: Re: bug#46048: split -n K/N loses data, sum of output files is smaller than input file.

From: Pádraig Brady <[email-masked]>
Date: Sun, 24 Jan 2021 16:58:43 +0000

On 24/01/2021 16:52, Pádraig Brady wrote:
> diff --git a/src/split.c b/src/split.c
> index 0660da13f..6aa8d50e9 100644
> --- a/src/split.c
> +++ b/src/split.c
> @@ -1001,7 +1001,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
>        }
>      else
>        {
> -      if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
> +      if (lseek (STDIN_FILENO, start, SEEK_SET) < 0)
>            die (EXIT_FAILURE, errno, "%s", quotef (infile));
>          initial_read = SIZE_MAX;
>        }

The same adjustment is needed in lines_chunk_split()
I'll add a test also.

cheers,
Pádraig