Subject: Re: bug#61386: [PATCH] cp,mv,install: Disable sparse copy on macOS

From: Paul Eggert <[email-masked]>
Date: Mon, 6 Mar 2023 15:48:07 -0800

On 3/6/23 03:13, Pádraig Brady wrote:
> On 06/03/2023 07:37, Paul Eggert wrote:
> The lseek /dev/null issue was only in your undef SEEK_DATA test patch,
> and already addressed in your final gnulib patch in the area, as 
> discussed at:
> https://lists.gnu.org/archive/html/bug-coreutils/2023-02/msg00081.html

Sorry,  I got confused about that issue versus other 'split' issues.

> Also immediately rejecting input where we can't determine the size is a 
> feature.
> I.e. the following is the expected behavior:
> 
>    $ : | split -n l/1
>    split: -: cannot determine file size

But 'split' can easily determine the size there: it's zero. 'split' 
doesn't need to use lseek to do that; a single 'read' will do.

> With the changes we now have:
> 
>    $ : | split -n l/1  # Creates an empty file
>    $ yes | split -n l/1
>    split: -: cannot determine file size
> 
> This is inconsistent, and an insidious issue that users may introduce to 
> scripts,
> that will only fail once input data hits a certain size.

That's OK, as lots of standard utilities already have that issue and 
users are OK with this. Users can't reasonably expect 'split -n' to work 
on infinitely-sized input such as the second example. At some point 
there is a limit.

It's a bit like 'sort' if you feed 'sort' longer and longer input lines, 
eventually it will fail and give you a diagnostic.

It'd be nicer if the limit of 'split' were larger than what's in current 
Git. If you'd prefer that we raise the limit further, by copying stdin 
into a temporary file first, I can write a patch to do that.

> Also there are a few `make syntax-check` issues in the new split code.

Ouch, sorry, I'm always forgetting that. Fixed by the attached patch. 
(Two of the issues were in 'split', one was elsewhere.)

> Would it be possible to revert this change in isolation?

We could revert the patch's effect (not sure if it's a simple revert, 
but I could easily generate such a patch). I'm hoping, though, that we 
can reach consensus on extending split's functionality instead, perhaps 
along the abovementioned lines.

[dropping bug-gnulib since this is no longer relevant to Gnulib.]

From a4778006c8f2b669afcc45456acf0d21f228208d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 6 Mar 2023 15:37:45 -0800
Subject: [PATCH] =?UTF-8?q?maint:=20pacify=20=E2=80=98make=20syntax-check?=
 =?UTF-8?q?=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Pádraig Brady (Bug#61386#226).
* src/split.c (parse_chunk): Use die instead of error.
(main): Quote a string.
* tests/local.mk (all_root_tests): Move du/apparent.sh from here ...
(all_tests): ... to here.
---
 src/split.c    | 6 +++---
 tests/local.mk | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/split.c b/src/split.c
index cc581b6c6..95d174a8b 100644
--- a/src/split.c
+++ b/src/split.c
@@ -1325,8 +1325,8 @@ parse_chunk (intmax_t *k_units, intmax_t *n_units, char const *arg)
       *n_units = parse_n_units (argend + 1, "",
                                 N_("invalid number of chunks"));
       if (! (0 < *k_units && *k_units <= *n_units))
-        error (EXIT_FAILURE, 0, "%s: %s", _("invalid chunk number"),
-               quote_mem (arg, argend - arg));
+        die (EXIT_FAILURE, 0, "%s: %s", _("invalid chunk number"),
+             quote_mem (arg, argend - arg));
     }
   else if (! (e <= OVERFLOW_OK && 0 < *n_units))
     strtoint_die (N_("invalid number of chunks"), arg);
@@ -1561,7 +1561,7 @@ main (int argc, char **argv)
 
   if (n_units == 0)
     {
-      error (0, 0, _("invalid number of lines: %s"), "0");
+      error (0, 0, _("invalid number of lines: %s"), quote ("0"));
       usage (EXIT_FAILURE);
     }
 
diff --git a/tests/local.mk b/tests/local.mk
index 1fe04235d..1e93290d0 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -118,7 +118,6 @@ all_root_tests =				\
   tests/dd/skip-seek-past-dev.sh		\
   tests/df/problematic-chars.sh			\
   tests/df/over-mount-device.sh			\
-  tests/du/apparent.sh				\
   tests/du/bind-mount-dir-cycle.sh		\
   tests/du/bind-mount-dir-cycle-v2.sh		\
   tests/id/setgid.sh				\
@@ -557,6 +556,7 @@ all_tests =					\
   tests/df/total-verify.sh			\
   tests/du/2g.sh				\
   tests/du/8gb.sh				\
+  tests/du/apparent.sh				\
   tests/du/basic.sh				\
   tests/du/bigtime.sh				\
   tests/du/deref.sh				\
-- 
2.39.2