Heads up, mv -x (--swap) option.
Rob Landley
rob at landley.net
Mon Mar 4 23:34:35 UTC 2024
FYI it was added to coreutils here:
https://github.com/coreutils/coreutils/commit/6cd2d5e5335b
And toybox here:
https://github.com/landley/toybox/commit/a2419ad52d48
mv -x takes exactly two arguments and calls:
renameat2(AT_FDCWD, argv[1], AT_FDCWD, argv[2], RENAME_EXCHANGE);
Which does an atomic exchange.
Rob
P.S. My toybox patch is fluffy because I support building a subset of the
commands on freebsd and macos, and didn't want to break cp/mv/install there
calling a linux-only syscall/flag, so I added a wrapper to lib/portability.c to
quarrantine the #ifdef. Both the syscall and the exchange flag for it were added
to linux in 2014, so maybe they've caught up by now or have an equivalent?
Dunno. I tweaked some help text while I was there, 80% of that patch is
basically noise to you guys. I haven't actually looked at the coreutils patch
because gplv3...
More information about the busybox
mailing list