
2 Jun
2021
2 Jun
'21
15:35
I had it written that way first, but as you pointed out, it can get weird when `mv` itself becomes unusable during the exchange. (`mv` is not a shell builtin on bash, unfortunately) I therefore think it's cleaner to have it in the binary, which is not a reusable utility but purpose-built for this script. The name "xmv" doesn't really imply atomicity to begin with, it's still doing what it says on the tin - exchanging two files. To avoid concerns about temp filenames and race conditions and whatnot, another way to handle this might be to unlink the file from the filesystem altogether and then relink that same inode into the FS somehow, but my POSIX-fu is not up to speed with how to accomplish that.