[latex3-commits] [git/LaTeX3-latex3-l3build] master: Support spaces in file names (fixes #76) (4fa1807)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Oct 25 09:35:59 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/4fa18076b96358a0cf7a92669ff1caedd7cb2772

>---------------------------------------------------------------

commit 4fa18076b96358a0cf7a92669ff1caedd7cb2772
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Oct 25 08:35:59 2018 +0100

    Support spaces in file names (fixes #76)
    
    Fingers crossed! Have to check in before testing cross-platform!


>---------------------------------------------------------------

4fa18076b96358a0cf7a92669ff1caedd7cb2772
 CHANGELOG.md               |    1 +
 l3build-file-functions.lua |   19 ++++++++++++++++++-
 l3build.lua                |   14 ++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d742537..8721d9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## Fixed
 
+- Support for spaces in directory names (fixes #76)
 - Support relative directories as argument to `--texmfhome`
 
 ## [2018-09-23]
diff --git a/l3build-file-functions.lua b/l3build-file-functions.lua
index bc462d3..ff2bff4 100644
--- a/l3build-file-functions.lua
+++ b/l3build-file-functions.lua
@@ -33,6 +33,7 @@ local chdir            = lfs.chdir
 local lfs_dir          = lfs.dir
 
 local execute          = os.execute
+local exit             = os.exit
 local getenv           = os.getenv
 local remove           = os.remove
 local os_time          = os.time
@@ -246,7 +247,23 @@ function abspath(path)
   chdir(path)
   local result = currentdir()
   chdir(oldpwd)
-  return gsub(result, "\\", "/")
+  return escapepath(gsub(result, "\\", "/"))
+end
+
+function escapepath(path)
+  if os_type == "windows" then
+    local path,count = gsub(path,'"','')
+    if count % 2 ~= 0 then
+      print("Unbalanced quotes in path")
+      exit(0)
+    else
+      return '"' .. path .. '"'
+    end
+  else
+    path = gsub(path,"\\ ","[PATH-SPACE]")
+    path = gsub(path," ","\\ ")
+    return gsub(path,"[PATH-SPACE]","\\ ")
+  end
 end
 
 -- For cleaning out a directory, which also ensures that it exists
diff --git a/l3build.lua b/l3build.lua
index cdf1dea..e87da95 100755
--- a/l3build.lua
+++ b/l3build.lua
@@ -95,6 +95,20 @@ end
 -- comes after any user versions
 build_require("variables")
 
+-- Ensure that directories are 'space safe'
+maindir       = escapepath(maindir) 
+docfiledir    = escapepath(docfiledir)
+sourcefiledir = escapepath(sourcefiledir)
+supportdir    = escapepath(escapepath(supportdir)
+testfiledir   = escapepath(testfiledir)
+testsuppdir   = escapepath(testsuppdir)
+builddir      = escapepath(builddir)
+distribdir    = escapepath(distribdir)
+localdir      = escapepath(localdir)
+testdir       = escapepath(testdir)
+typesetdir    = escapepath(typesetdir)
+unpackdir     = escapepath(unpackdir)
+
 -- Tidy up the epoch setting
 -- Force an epoch if set at the command line
 -- Must be done after loading variables, etc.





More information about the latex3-commits mailing list