I'm working on a deploy script which wants to update a symlink atomically. I intend to use a command like
$ ln -s new current_tmp && mv -Tf current_tmp current
(Credit to here for details on why this works).
However, not all versions of mv
support the -T
option. How can I reliably determine if a system supports it before using it?
Is the a better way than creating a different file and attempting to mv
that file instead using the -T
option (and checking if that was successful) so I can know if the current system supports that option? Then I can run the correct command for that system.
Thanks for your help.