On 22/07/2023 18:37, Paul Eggert wrote:
On 2023-07-22 03:19, Pádraig Brady wrote:
Given the subtleties in this area,
I'd be reluctant to adjust diagnostics here.
I looked into this a bit more. Given "mv dir e" where e/dir is an
existing nonempty directory, 7th Edition Unix fails this way:
mv: e/dir exists
Solaris 10 mv fails this way:
mv: cannot rename dir to e/dir: File exists
Coreutils 5.93 fails this way:
mv: cannot overwrite directory `e/dir'
Current coreutils fails this way:
mv: cannot move 'dir' to 'e/dir': Directory not empty
macOS fails this way:
mv: rename dir to e/dir: Directory not empty
If you ask me, none of these are all that good. Current coreutils and
macOS give a confusing "Directory not empty" message (which directory?).
Solaris 10 has a similar confusion. 7th Edition and coreutils 5.93 don't
print strerror (errno).
All things considered, how about if we go back to something like
coreutils 5.93, except output strerror (errno) too? That is, something
like this:
mv: cannot overwrite 'e/dir': Directory not empty
This focuses the user on the problem, avoiding confusion from the
irrelevant source file name. We'd use this format if renameat fails with
an errno that means the problem must be with the destination, and stick
with the current format otherwise. Affected errno values would be
EDQUOT, EISDIR, ENOSPC, EEXIST, ENOTEMPTY.
Sounds good.
Thanks for looking into all the details.
Padraig