1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

split: port ‘split -n N /dev/null’ better to macOS

* src/split.c (input_file_size): Do not bother with lseek if the
initial read probe reaches EOF, since the file size is known then.
This works better on macOS, which doesn’t allow lseek on /dev/null.
Do not special-case size-zero files, as the issue can occur
with any size file (though /proc files are the most common).
If the current position is past end of file, treat this as
size zero regardless of whether the file has a usable st_size.
Pass through lseek -1 return values rather than using ‘return -1’;
this makes the code a bit easier to analyze (and a bit faster).
Avoid undefined behavior if the size calculation overflows.
(lines_chunk_split): Do not bother with lseek if it would have
no effect if successful.  This works better on macOS, which
doesn’t allow lseek on /dev/null.
* tests/split/l-chunk.sh: Adjust to match fixed behavior.
This commit is contained in:
Paul Eggert
2023-03-04 11:42:16 -08:00
parent fe64f8be01
commit aa266f1b3d
3 changed files with 40 additions and 37 deletions

4
NEWS
View File

@@ -54,6 +54,10 @@ GNU coreutils NEWS -*- outline -*-
long been documented to be platform-dependent.
[bug introduced 1999-05-02 and only partly fixed in coreutils-8.14]
split with -l or -n no longer misbehaves on small piped input, on
small GNU/Linux /proc files, or on macOS /dev/null.
[bug introduced in coreutils-8.8]
stty ispeed and ospeed options no longer accept and silently ignore
invalid speed arguments, or give false warnings for valid speeds.
Now they're validated against both the general accepted set,