[latex3-commits] [l3svn] 06/07: l3build: Make file writing after edit atomic

noreply at latex-project.org noreply at latex-project.org
Thu Oct 8 19:31:51 CEST 2015


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit 2b787fb88b8b072cc02422d06084478be0849efa
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Oct 8 18:17:11 2015 +0100

    l3build: Make file writing after edit atomic
---
 l3build/l3build.dtx |    1 +
 l3build/l3build.lua |    3 +++
 2 files changed, 4 insertions(+)

diff --git a/l3build/l3build.dtx b/l3build/l3build.dtx
index 97ba894..04c51ca 100644
--- a/l3build/l3build.dtx
+++ b/l3build/l3build.dtx
@@ -113,6 +113,7 @@
 \luavarset{unpacksuppfiles} {\{~\}}       {Files needed to support unpacking when \enquote{sandboxed}.}
 \luavarset{versionfiles}    {\{"*.dtx"\}} {Files for automatic version editing.}
 \luavarseparator
+\luavarset{bakext} {".bak"} {Extension of backup files.}
 \luavarset{lvtext} {".lvt"} {Extension of test files.}
 \luavarset{tlgext} {".tlg"} {Extension of test file output.}
 \luavarset{lvtext} {".lve"} {Extension of auto-generating test file output.}
diff --git a/l3build/l3build.lua b/l3build/l3build.lua
index df8cce3..c7075c9 100644
--- a/l3build/l3build.lua
+++ b/l3build/l3build.lua
@@ -155,6 +155,7 @@ typesetcmds  = typesetcmds  or ""
 versionform  = ""
 
 -- Extensions for various file types: used to abstract out stuff a bit
+bakext = bakext or ".bak"
 logext = logext or ".log"
 lveext = lveext or ".lve"
 lvtext = lvtext or ".lvt"
@@ -1754,10 +1755,12 @@ function setversion()
         string.gsub(lines, os_newline .. "$", "")
       end
       -- Write the new file
+      ren(".", file, file .. bakext)
       local f = io.open(file, "w")
       io.output(f)
       io.write(lines)
       io.close(f)
+      rm(".", file .. bakext)
     end
   end
   local date = os.date("%Y-%m-%d")

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list