[latex3-commits] [git/LaTeX3-latex3-l3build] popen_yes: Avoid temporary file when passing "y" in unpack (11be65e)

Marcel Fabian Krüger zauguin at gmail.com
Sun Feb 9 02:08:58 CET 2020


Repository : https://github.com/latex3/l3build
On branch  : popen_yes
Link       : https://github.com/latex3/l3build/commit/11be65e5c92c8e0cee1f8be93b31682bca41ab04

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

commit 11be65e5c92c8e0cee1f8be93b31682bca41ab04
Author: Marcel Fabian Krüger <zauguin at gmail.com>
Date:   Sun Feb 9 02:08:58 2020 +0100

    Avoid temporary file when passing "y" in unpack


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

11be65e5c92c8e0cee1f8be93b31682bca41ab04
 l3build-unpack.lua | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/l3build-unpack.lua b/l3build-unpack.lua
index 89bbfaa..0c5e5b1 100644
--- a/l3build-unpack.lua
+++ b/l3build-unpack.lua
@@ -73,26 +73,20 @@ bundleunpack = bundleunpack or function(sourcedirs, sources)
   end
   for _,i in ipairs(unpackfiles) do
     for j,_ in pairs(tree(unpackdir, i)) do
-      -- This 'yes' business is needed to pass a series of "y\n" to
-      -- TeX if \askforoverwrite is true
-      -- That is all done using a file as it's the only way on Windows and
-      -- on Unix the "yes" command can't be used inside execute (it never
-      -- stops, which confuses Lua)
-      execute(os_yes .. ">>" .. localdir .. "/yes")
       local path, name = splitpath(j)
       local localdir = abspath(localdir)
-      errorlevel = run(
-        unpackdir .. "/" .. path,
+      errorlevel = io.popen(
+        "cd " .. unpackdir .. "/" .. path .. os_concat ..
         os_setenv .. " TEXINPUTS=." .. os_pathsep
           .. localdir .. (unpacksearch and os_pathsep or "") ..
         os_concat  ..
         os_setenv .. " LUAINPUTS=." .. os_pathsep
           .. localdir .. (unpacksearch and os_pathsep or "") ..
         os_concat ..
-        unpackexe .. " " .. unpackopts .. " " .. name .. " < "
-          .. localdir .. "/yes"
-          .. (options["quiet"] and (" > " .. os_null) or "")
-      )
+        unpackexe .. " " .. unpackopts .. " " .. name
+          .. (options["quiet"] and (" > " .. os_null) or ""),
+        "w"
+      ):write(string.rep("y\n", 300)):close()
       if errorlevel ~=0 then
         return errorlevel
       end





More information about the latex3-commits mailing list.