[Toybox] more gnu nonsense: cp -n
Rob Landley
rob at landley.net
Wed Apr 3 03:13:39 PDT 2024
On 4/2/24 01:35, Ryan Prichard wrote:
> Apparently upstream coreutils "cp -n" changed between 9.1 and 9.2, and the
> Debian maintainers reverted the change temporarily(?) and also added the
> "non-portable" error.
>
> In coreutils 9.1 and older, "cp -n" quietly skipped a file if the
> destination existed, but as of 9.2, it instead prints an error and exits with
> non-zero at the end. (I saw some stuff about "immediately failing" on the Debian
> bug, but AFAICT, cp keeps going and fails at the end.) It does look like the new
> 9.2+ behavior matches "cp -n" on macOS (14.3.1) (and probably FreeBSD but I
> didn't test that).
In toybox, I tend to repeat an option to get that sort of behavior, so I'd do:
cp -n thingy... - skip files, no error
cp -nn thingy... - skip files, with error
That way the existing behavior doesn't change, and old versions that don't
understand the doubling still provide the old behavior (because cp -n -n = cp -n
by default) without erroring out on an unknown flag or consuming more namespace.
See toybox's "ls -ll" (shows nanoseconds) or "lsusb -nn" (numeric AND
non-numeric output) for examples. And yes, debian handles "ls -ll" just fine. :)
Rob
More information about the Toybox
mailing list