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). https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1058752 Someone complained to upstream, but it didn't go anywhere: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62572 New behavior: $ docker run -it fedora:39 bash -l [root@137183bb9d76 /]# cp --version | head -n1 cp (GNU coreutils) 9.3 [root@137183bb9d76 /]# mkdir a b; touch a/x a/y [root@137183bb9d76 /]# cp -rnv a b; echo $? 'a' -> 'b/a' 'a/x' -> 'b/a/x' 'a/y' -> 'b/a/y' 0 [root@137183bb9d76 /]# cp -rnv a b; echo $? cp: not replacing 'b/a/x' cp: not replacing 'b/a/y' 1 [root@137183bb9d76 /]# rm -f b/a/x; cp -rnv a b; echo $?; ls b/a 'a/x' -> 'b/a/x' cp: not replacing 'b/a/y' 1 x y [root@137183bb9d76 /]# rm -f b/a/y; cp -rnv a b; echo $?; ls b/a cp: not replacing 'b/a/x' 'a/y' -> 'b/a/y' 1 x y Old behavior: $ docker run -it fedora:38 bash -l [root@e296da330d05 /]# cp --version | head -n1 cp (GNU coreutils) 9.1 [root@e296da330d05 /]# mkdir a b; touch a/x a/y [root@e296da330d05 /]# cp -rnv a b; echo $? 'a' -> 'b/a' 'a/x' -> 'b/a/x' 'a/y' -> 'b/a/y' 0 [root@e296da330d05 /]# cp -rnv a b; echo $? 0 -Ryan On Mon, Apr 1, 2024 at 10:09 PM Rob Landley <[email protected]> wrote: > On 4/1/24 10:31, enh via Toybox wrote: > > hadn't seen this one before... > > > > cp: warning: behavior of -n is non-portable and may change in future; > > use --update=none instead > > > > (consider me skeptical that a system without -n is going to have > > --update=none...) > > Define non-portable? Freebsd 14 has -n, macos has -n, busybox cp has -n, > and of > course toybox (and thus android) has -n. > > Meanwhile: > > $ ./busybox cp --update=none one two > cp: option '--update' doesn't allow an argument > root@freebsd:~ # cp --update=none one two > cp: illegal option -- - > root@freebsd:~ # cp --update=none one two > cp: illegal option -- - > $ toybox cp --update=none one two > cp: Unknown option 'update=none' (see "cp --help") > > Those clowns are explicitly advocating for a LESS portable option. > > This is why I'm not removing "egrep", which is a shell wrapper on my devuan > system by the way: > > $ which egrep > /bin/egrep > $ cat /bin/egrep > #!/bin/sh > exec grep -E "$@" > > At least THAT one is easy for distributions to keep doing regardless of > gnu/stupid. > > If the solution for cp -n isn't "distro patches out the stupid", then > "install > busybox cp" or just "use alpine". Spurious warnings from gnu are just that: > spurious. > > Rob > _______________________________________________ > Toybox mailing list > [email protected] > http://lists.landley.net/listinfo.cgi/toybox-landley.net >
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
