GNU bug report logs - #69532
mv's new -x option should be made orthogonal to -t/-T/default

Previous Next

Package: coreutils;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Mon, 4 Mar 2024 00:46:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Petr Malat <oss <at> malat.biz>
Cc: 69532 <at> debbugs.gnu.org
Subject: bug#69532: mv's new -x option should be made orthogonal to -t/-T/default
Date: Mon, 4 Mar 2024 16:24:27 -0800
On 3/4/24 15:37, Petr Malat wrote:
> Why do you expect this?

I expect it because mv has always treated destination directories that 
way. This has been true since the 1970s. We should not change this basic 
mode of operation.


>> To fix this, 'mv -x' should respect the usual mv behavior with respect to
>> directories. For example, when D is a directory 'mv -x A B C D' should act
>> like 'mv A B C D' except that D's old entries should be renamed back to A B
>> and C. And the -t and -T options should work with -x the same way they work
>> when -x is not specified.
> 
> I do not think this is a good idea, because that operation is not
> atomic.

There's nothing wrong with 'mv -x a b c d/' being nonatomic. "mv a b c 
d/" is not atomic either, and that's fine too.


> Probably, the user wants to prepare a temporary directory
> instead and then atomically swap it with the directory in use.

This usage was not at all obvious to me. If it's the intended use, I 
suggest inventing a new command, or adding -x to the 'rename' command 
instead. Pushing this flag onto 'mv', without making the flag reasonably 
orthogonal to mv's other options, would be a mistake because it would 
cause too much confusion.


> Supporting swap for more than 2 files also brings a problem, when
> the operation fails as then one doesn't know what has been swapped
> and what not.

I don't see why not. The user can look at mv's diagnostics. It's the 
same as regular "mv a b c d/".





This bug report was last modified 1 year and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.