On Okt 17 2017, Tino Calancha <tino.calancha@gmail.com> wrote:
emacs -Q:
(let ((foo (make-temp-file "foo")) mode)
(with-file-modes #o755 (write-region "" nil foo nil 0))
;; (set-file-modes foo #o755)
(setq mode (nth 8 (file-attributes foo)))
(delete-file foo) mode)
=> "-rw-------"
To set foo file permissions to "-rwxr-xr-x" I need uncomment
(set-file-modes foo #o755) above.
Why? Is for security reasons?
make-temp-file already creates the file (with restrictive modes), so
with-file-modes has no effect (write-region does not change the mode of
existing files). But write-region also never sets the x bits in the
first place, it uses #o666 as the base mode.