diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm index c522b74b5..e8a8fd946 100644 --- a/module/system/base/compile.scm +++ b/module/system/base/compile.scm @@ -59,7 +59,9 @@ (proc tmp) ;; Chmodding by name instead of by port allows this chmod to ;; work on systems without fchmod, like MinGW. - (chmod template (logand #o0666 (lognot (umask)))) + (let ((perms (or (false-if-exception (stat:perms (stat reference))) + (lognot (umask))))) + (chmod template (logand #o0666 perms))) (close-port tmp) (rename-file template filename)) (lambda args