News for hackers. Stuff that matters.
Re:Take care editing bash scripts (2019) by kps on Wednesday May 06, 2020 @10:34AM (#23091403)
> the modified file is actually written as a new file under the same filename.

That can't be true, because it would break links.

Re:Take care editing bash scripts (2019) by nitrogen on Wednesday May 06, 2020 @11:13AM (#23091861)
Only hardlinks, which are rare for scripts in my experience, and not symbolic links.

I have used the same overwrite-by-rename technique in very long-running embedded processes because renaming a file is atomic on common local Linux filesystems.

Re:Take care editing bash scripts (2019) by fl0wenol on Wednesday May 06, 2020 @12:09PM (#23092669)
In vim, it depends on the value of backupcopy. If set to "auto" (a default-default on linux, but maybe not for a specific distribution's default vimrc), the behavior is to check to see if the number of hardlinks to a file is greater than one, and then write the modified version in place, otherwise use the write and rename strategy.

See: https://github.com/vim/vim/blob/95f0b6e5a5e5861da34cc064c601...