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