Skip to content

Commit

Permalink
Low level failures detected+debug mode in execute
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaurens committed Jun 27, 2024
1 parent df09ec1 commit 3ffff74
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ this project uses date-based 'snapshot' version identifiers.

## [Unreleased]

### Changed
- Respect `--debug` in `execute` invocations

### Fixed
- Global `typesetopts` no longer ignored for `luatex` and `lualatex` (issue \#351)
- Handling of spaces in options
- Low level failures detected

## [2024-05-27]

Expand Down
3 changes: 2 additions & 1 deletion l3build-check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ local sort = table.sort
local utf8_char = unicode.utf8.char

local exit = os.exit
local execute = os.execute
local remove = os.remove

local execute = require"l3buildlib".execute

-- randomise the random numbers
math.randomseed( os.time() )

Expand Down
10 changes: 6 additions & 4 deletions l3build-file-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ local currentdir = lfs.currentdir
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
Expand All @@ -46,6 +45,9 @@ local gsub = string.gsub

local insert = table.insert

local l3b = require"l3buildlib"
local execute = l3b.execute

-- Convert a file glob into a pattern for use by e.g. string.gub
-- Based on https://github.com/davidm/lua-glob-pattern
-- Simplified substantially: "[...]" syntax not supported as is not
Expand Down Expand Up @@ -236,12 +238,12 @@ function cp(glob, source, dest)
errorlevel = execute(
'xcopy /y /e /i "' .. unix_to_win(p.cwd) .. '" '
.. unix_to_win(dest .. '/' .. escapepath(p.src)) .. ' > nul'
) and 0 or 1
)
else
errorlevel = execute(
'xcopy /y "' .. unix_to_win(p.cwd) .. '" '
.. unix_to_win(dest .. '/') .. ' > nul'
) and 0 or 1
)
end
else
-- Ensure we get similar behavior on all platforms
Expand All @@ -251,7 +253,7 @@ function cp(glob, source, dest)
end
errorlevel = execute(
"cp -RLf '" .. p.cwd .. "' " .. dest
) and 0 or 1
)
end
if errorlevel ~=0 then
return errorlevel
Expand Down
54 changes: 54 additions & 0 deletions l3buildlib.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--[[
File l3buildlib.lua Copyright (C) 2024 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
license or (at your option) any later version. The latest version
of this license is in the file
https://www.latex-project.org/lppl.txt
This file is part of the "l3build bundle" (The Work in LPPL)
and all files in that bundle must be distributed together.
-----------------------------------------------------------------------
The development version of the bundle can be found at
https://github.com/latex3/l3build
for those people who are interested.
--]]

--[[
The very first call:
require"l3buildlib"
must occur before everything else.
Then
local l3b = require"l3buildlib"
After that, we have access to `l3b.execute`.
]]

local M = { -- the return table
_DESCRIPTION = "l3build core library"
}

local execute = os.execute -- Lua version 5.1 see https://tug.org/pipermail/luatex/2015-November/005535.html

---Execute a command sticking to version 5.1 output
---
---`texlua` 1.18 uses Lua 5.3 except for `os.execute` which is still 5.1.
---First print the argument when debugging.
---@param command string?
---@return integer
function M.execute(command)
if options.debug then
print('l3build execute: `'..tostring(command)..'`')
end
---@diagnostic disable-next-line: return-type-mismatch
return execute(command)
end

return M

0 comments on commit 3ffff74

Please sign in to comment.