mv -T is a GNU extension to
Is there a robust way (race-free, portable, and otherwise without "gotchas") to do the equivalent of
mv -T dir1 dir2?
To be clear:
I DO NOT want this to ever result in
dir2exists, I want the command to fail. If
dir1is moved at all, it must become
I DO NOT want to move out every child one-by-one. I want to move the directory itself.
I DO want to avoid race conditions. It's trivial to test if
dir2exists first, but then it might be created after the check but before the move.