I have, for reasons that will become obvious in a week or so, been looking at
text editors and what happens when you save a file. For example, if we are editing the file
filename.txt, different things will happen when you
save the file depending on which editor you are using.
VIM is fairly straight forward in that it renames the original file
filename.txt~, writes the modified
filename.txt, and then if that is successful
Emacs does roughly the same thing as VIM, but by default doesn't clean up the
Eclipse is by far the simplest, truncating
to a length of 0 and then writing the new contents.
Gedit is by far the most byzantine, first it writes the contents of the modified buffer
to a hidden file
.gedit-save-NNNN, then it renames the original file
filename.txt~, then renames
and finally deletes
What makes Gedit really stand out from other text editors is that
if for some reason the filesystem doesn't support 'rename' then Gedit refuses
to save the file, as opposed to VIM and Emacs which will just write new
filename.txt. As you can imagine that's controversial
behavior and there's
a long and painful bug thread on it, which is filled with all the painful things
you'd expect it to be filled with, like claiming it's not a bug, or that
the bug is in some other piece of software, or that it's not a problem
under 'normal' usage, or that any other way of saving files is unsafe.
Like I said, painful.
But I'm willing to believe there are even more complex cases, and if you know of an editor that has an even more convoluted save routine I'd be glad to hear about it.