Subject: Re: cp --no-clobber behavior has changed

From: Christoph Anton Mitterer <[email-masked]>
Date: Sat, 01 Apr 2023 02:05:15 +0200

In principle I have no strong opinion on what the behaviour should be.

But if one strictly follows the POSIX wording:

>    The following exit values shall be returned:
>     0
>        All input files were [copied/moved] successfully.
>    >0
>        An error occurred.

The change seems to make sense, as one could argue that the above ain't
the case with -n if the destination already exists.

It's however open to debate whether --no-clobber - were it in POSIX -
would have fallen into that spirit.

But at least as of corutils 9.1 's cp info page it was documented as:
>An exit status of zero indicates success, and a nonzero value
>indicates failure.

together with:

> ‘-n’
> ‘--no-clobber’
>     Do not overwrite an existing file; silently do nothing instead.
>     This option overrides a previous ‘-i’ option.  This option is
>     mutually exclusive with ‘-b’ or ‘--backup’ option.

that doesn't seem like failure to me.

So it kinda breaks the "promise" made by the documentation.

I like Pádraig's idea in message #26... but no idea whether it should
be more POSIX like (thus non-zero when nothing was copied) or more
backwards compatible.

Cheers,
Chris.