Skip to content

Commit eae9fed

Browse files
committed
fix(openssl/windows): the batch needs CRLF — cmd resumes a called script by file offset
Third run, and this time the log shows the batch working right up to the point it matters: [bat] vspath=C:\Program Files\Microsoft Visual Studio\18\Enterprise ** Visual Studio 2026 Developer Command Prompt v18.8.2 [vcvarsall.bat] Environment initialized for: 'x64' …and then nothing. No 'toolset ready', no 'where perl', no RESULT, exit 0. cmd reads a batch file by FILE OFFSET and that bookkeeping assumes CRLF. With the LF-only file the previous commit introduced, returning from `call` resumes at the wrong position and lands on EOF — a script that reports success having done nothing past its first call. This also corrects the reasoning in that commit: it claimed io.writefile translates \n to CRLF on windows, so emitting \r\n would double it. The run disproves that — io.writefile writes bytes verbatim, which is exactly why the LF-only file reached cmd as LF-only. Line endings go back to \r\n; everything else from that commit (per-step logging, RESULT= reporting rather than trusting os.exec) stays, and is what made this diagnosable at all.
1 parent 6fdf286 commit eae9fed

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

pkgs/c/compat.openssl.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,14 @@ local function _install_windows_impl()
464464
-- announces itself into the log BEFORE running, and the script always
465465
-- exits 0 after recording RESULT=<code>, which is what Lua then reads.
466466
--
467-
-- Written with plain \n: io.writefile on windows already produces CRLF, and
468-
-- emitting \r\n here would give \r\r\n — a batch file whose stray CR ends
469-
-- up inside `set` values and breaks parsing in ways that look like nothing
470-
-- happened at all.
467+
-- CRLF line endings are REQUIRED, and this was established the hard way.
468+
-- io.writefile writes bytes verbatim (it does not translate \n), and with
469+
-- an LF-only batch the run got as far as `call "%VCVARS%"` — the log even
470+
-- shows "[vcvarsall.bat] Environment initialized for: 'x64'" — and then
471+
-- stopped dead: no further echo, no RESULT, exit 0. cmd reads a batch by
472+
-- FILE OFFSET and its bookkeeping assumes CRLF, so on returning from a
473+
-- `call` it resumes at the wrong position and hits EOF. The symptom is a
474+
-- script that "succeeds" having done nothing after the first call.
471475
local logw = tostring(logf):gsub("/", "\\")
472476
local prefw = tostring(prefix):gsub("/", "\\")
473477
io.writefile(bat, table.concat({
@@ -499,7 +503,7 @@ local function _install_windows_impl()
499503
'if errorlevel 1 ( echo [bat] RESULT=22 nmake install_sw failed >> "' .. logw .. '" & exit /b 0 )',
500504
'echo [bat] RESULT=0 >> "' .. logw .. '" 2>&1',
501505
"exit /b 0",
502-
}, "\n") .. "\n")
506+
}, "\r\n") .. "\r\n")
503507

504508
note("wrote " .. bat .. "; running it")
505509
local batw = tostring(bat):gsub("/", "\\")

0 commit comments

Comments
 (0)