bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#81377: mv -Tn suceeds if target directory exists, no error printed


From: Pádraig Brady
Subject: bug#81377: mv -Tn suceeds if target directory exists, no error printed
Date: Wed, 8 Jul 2026 19:07:46 +0100
User-agent: Mozilla Thunderbird Beta

On 08/07/2026 13:51, Florian Weimer via GNU coreutils Bug Reports wrote:
* Florian Weimer via:

Based on the documentation, I would have expected an error in this case.

mkdir a a/1 b b/2
mv -Tn a b

Exit status is zero.  The only relevant system call in the strace output
is this one:

renameat2(AT_FDCWD, "a", AT_FDCWD, "b", RENAME_NOREPLACE) = -1 EEXIST (File 
exists)

Right the documentation got out of sync a bit.

We changed the behavior to exiting with failure in:
https://github.com/coreutils/coreutils/commit/7a69df889
Though there was push back on that due to scripts breaking,
so it was reverted in:
https://github.com/coreutils/coreutils/commit/9907b6f5d

However I failed to update the mv -n info docs accordingly.

In some quick testing here I see mv -n silently fails on solaris,
but (like Linux) silently skips on FreeBSD.
So we should deprecate (non POSIX) -n for mv as we've
already done for cp.

I'll push the attached to address this documentation issue.


Seen with: coreutils-9.7-9.fc43.x86_64

I see that there is a hint in the -n description that the exit status
may not be what users expects.  But it means that this claim in the
manual is slightly misleading:

| However, if ‘mv -T /tmp/source /tmp/dest’ succeeds, there is no
| question that ‘/tmp/source’ was renamed to ‘/tmp/dest’.

The above is OK I think, as it doesn't mention -n.

Marking this as done.

thanks,
Padraig

Attachment: mv-n-doc.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]