On 2024-01-28 05:22, Pádraig Brady wrote:
At this stage it seems best for us go back to the original Linux
behiavor (use case 3),
and to silently deprecate -n in docs to document the portability issues
with it.
I'm not sure reverting would be best. It would introduce more confusion,
and would make coreutils incompatible with FreeBSD again.
The recent Debian change indicates that their intent is to move to the
FreeBSD behavior too. This would improve cross-platform portability and
I don't think we should discourage that.
$ cp -n /bin/true tmp
cp: warning: behavior of -n is non-portable and may change in future; use
--update=none instead
This is problematic as:
- It's noisy
Yes that's a problem, and I doubt whether we should mimic Debian.
- There is no way to get the behavior of indicating failure if existing files
present
Yes, it's not a good place to be. Surely current coreutils is better
than what Debian is doing.
- The --update=none advice is only portable to newer coreutils
True, but that's not a deal-killer. No advice that we give can be 100%
portable to all platforms.
We should also provide --update=noclobber for use case 1.
Having the control on the --update option, allows use to more clearly
deprecate -n.
Adding an --update=noclobber sounds like a good thing to do.
Another possibility is to add a warning that is emitted only at the end
of 'cp'. The warning would occur only if the exit code differs because
of this cp -n business. We could stretch things a bit and have a
configure-time option --enable-compat-warnings that builders like Debian
could use if they want such warnings.