coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] mv: add --swap (-s) option to atomically swap 2 paths


From: Petr Malat
Subject: Re: [PATCH] mv: add --swap (-s) option to atomically swap 2 paths
Date: Sat, 2 Mar 2024 22:45:59 +0100

Hi!
On Sat, Mar 02, 2024 at 11:01:42AM +0000, Padraig Brady wrote:
> > > I have modified mv, because for me it would be a logical place where
> > > to look for such a feature, and to make something usable, it must be
> > > easy to find.
> > 
> > I used "mv -x" for it, but if you have a strong preference for -s it hasn't 
> > been
> > in a release version yet.
> > 
> > I can submit a patch to busybox to add it there if we agree on a UI. (I 
> > will not
> > be adding a "replace" command to toybox: mv already replaces files and this 
> > is a
> > flag to the rename() system call that "mv" is already built around. This is 
> > an
> > atomic exchange, the new flag is RENAME_EXCHANGE, hence "-x" meaning 
> > exchange.)
> 
> Ok so there seems to be a bit of consensus for adding this to mv.
> 
> I've a slight preference for --swap, and that's short enough
> that there is little benefit to a short option.
> 
> I realize toybox nor bsd support long options, so since -x is already used by 
> toybox
> we can use that for compat.  Also install(1) already has -s taken, and this 
> functionality
> might also be a consideration for use there.
> So how about -x,--swap as the short and long options?
> Should we add this to install(1) ?
> 
> Petr, I've adjusted your patch a bit to better diagnose the "not supported" 
> case,
> which is also used to make the test more robust, when run on (file) systems
> that don't support the option.
> 
> I'll apply this soon, after waiting a while for comment.

The change looks good. If I would know this feature is available in
another implementation of mv, I would use the same options for it.

Thanks for the update,
  Petr



reply via email to

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