Skip to content

Commit

Permalink
Support spaces in file names (fixes #76)
Browse files Browse the repository at this point in the history
Fingers crossed! Have to check in before testing cross-platform!
  • Loading branch information
josephwright committed Oct 25, 2018
1 parent 34bb18f commit 4fa1807
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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]
Expand Down
19 changes: 18 additions & 1 deletion l3build-file-functions.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions l3build.lua
Expand Up @@ -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.
Expand Down

0 comments on commit 4fa1807

Please sign in to comment.