bug-coreutils
[Top][All Lists]
Advanced

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

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


From: Paul Eggert
Subject: bug#69532: mv's new -x option should be made orthogonal to -t/-T/default
Date: Sat, 16 Mar 2024 23:10:50 -0700
User-agent: Mozilla Thunderbird

On 2024-03-05 06:16, Pádraig Brady wrote:
I think I'll remove the as yet unreleased mv --swap from coreutils, given that
util-linux is as widely available as coreutils on GNU/Linux platforms.

Although removing that "mv --swap" implementation was a win, I don't think we can simply delegate this to util-linux's exch command. Exchanging files via a renameat-like call is not limited to the Linux kernel; it's also possible on macOS via renameatx_np with RENAME_SWAP, and there have been noises about adding similar things to other operating systems.

I just now added support for macOS renameatx_np to Gnulib, so coreutils does not need to worry about the macOS details; it can simply use renameatu with the Linux flags. See:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=af32ee824ee18255839f9812b8ed61aa5257a82b

Even with Linux it's dicey. People may have older util-linux installed and so lack the 'exch' utility; this is true for both Fedora 39 and Ubuntu 23.10, the current releases. Ubuntu is also odd in that it doesn't install all the util-linux utilities as part of the util-linux package, so it's not clear what they will do with 'exch'.

So I propose that we implement the idea in coreutils in a better way, that interacts more nicely with -t, -T, etc. Also, I suggest using the Linuxish name "--exchange" instead of the macOSish name "--swap", and (for now at least) not giving the option a single-letter equivalent as I expect it to be useful from scripts, not interactively.

After looking at various ways to do it I came up with the attached proposed patch. This should work on both GNU/Linux and macOS, if your OS is recent enough and the file system supports atomic exchange.

Attachment: 0001-mv-new-option-exchange.patch
Description: Text Data


reply via email to

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