OCamlPro / ocp-indent

Indentation tool for OCaml, to be used from editors like Emacs and Vim.
http://www.typerex.org/ocp-indent.html
Other
200 stars 63 forks source link

Proper handling of symbolic links and file_perm #293

Closed thomasblanc closed 5 years ago

thomasblanc commented 5 years ago

What happened before:

ocp-indent -iwould first output in a fresh temporary file then mv that file to the original one.

Doing that overwrites file permission and transforms symlinks into copies, which is probably not the expected behavior (unless you don't know how to do chmod).

The new version does the same but makes sure to overwrite the linked file and to preserve file permissions.

I did not handle the case of a file under a different uid/gid, but @AltGr agreed that "why would anyone need that anyway?"

Noteworthy information: this adds a dependency to Unix.

AltGr commented 5 years ago

Thanks!