On 3/21/24 14:45, Bernhard Voelker wrote: > On 3/21/24 00:56, Paul Eggert wrote: >> On 3/20/24 15:53, Bernhard Voelker wrote: >> Yes, that's the expected behavior for this contrived case. Just as one >> would get odd behavior if one did the same thing without --exchange. > > There's another which is not consistent with/without --exchange: > >   $ src/mv -v a a >   src/mv: 'a' and 'a' are the same file > >   $ src/mv -v --exchange a a >   renamed 'a' -> 'a' > > RENAME_EXCHANGE is allowed (but useless?) for 1 file. Yes, thanks, --exchange should act more like non --exchange there. > BTW: shouldn't the -v diagnostic better say "exchanged 'a' <-> 'a'" > because that's what happened? Good suggestion. > It seems that -i is skipped: > >   $ src/mv -iv --exchange a b >   renamed 'a' -> 'b' Yes, I suppose -i should be treated similarly too. I installed the attached patches to do the above. (Basically, the problem was that my earlier patches were too ambitious; these patches scale things back to avoid some optimizations so that mv --exchange is more like ordinary mv.) The first patch simplifies the code (and fixes a diagnostic to be more useful) without otherwise changing behavior; it's more of a refactoring. The second patch does the real work. Thanks again.