From 3f8a972c9c6df4027b78b16141a924c16f2f1f65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 20:30:22 +0000 Subject: [PATCH 1/3] Initial plan From 20091dd2d1c9f2844dc115b1b6daaecf326d3715 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 20:32:09 +0000 Subject: [PATCH 2/3] Use OS-specific line endings for scriptum example Agent-Logs-Url: https://github.com/smardine/ConsulScriptum/sessions/86883894-b8d7-43c3-a1ca-bff06000acee Co-authored-by: smardine <13467840+smardine@users.noreply.github.com> --- src/consul/consul.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/consul/consul.lua b/src/consul/consul.lua index 9d62efb..4edeae0 100644 --- a/src/consul/consul.lua +++ b/src/consul/consul.lua @@ -2863,9 +2863,17 @@ consul.console.write( f:close() else log:debug("Creating example script: " .. consul.scriptum.path_example) - f = consul.io_open(consul.scriptum.path_example, "w") + -- Detect OS via path separator + local is_windows = package.config:sub(1, 1) == '\\' + local line_ending = is_windows and "\r\n" or "\n" + + -- Normalize line endings then apply the correct one for the current OS + local script_content = consul.scriptum.example_script:gsub("\r\n", "\n"):gsub("\n", line_ending) + + -- Write in binary mode to prevent automatic line ending conversion + f = consul.io_open(consul.scriptum.path_example, "wb") if f then - f:write(consul.scriptum.example_script) + f:write(script_content) f:close() end end From 3e36c308ce4f6ef63a4cee001a58509217362289 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 May 2026 07:28:13 +0000 Subject: [PATCH 3/3] Fix macOS scriptum loading and execution Agent-Logs-Url: https://github.com/smardine/ConsulScriptum/sessions/3444523f-14d5-4b9e-a318-17132e8cf951 Co-authored-by: smardine <13467840+smardine@users.noreply.github.com> --- src/consul/consul.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/consul/consul.lua b/src/consul/consul.lua index 4edeae0..108eb4d 100644 --- a/src/consul/consul.lua +++ b/src/consul/consul.lua @@ -2915,10 +2915,12 @@ consul.console.write( log:error("Could not open scriptum file, this should never happen " .. path) return end - for line in f:lines() do + local content = f:read("*a") or "" + f:close() + content = content:gsub("\r\n", "\n"):gsub("\r", "\n") + for line in string.gmatch(content, "[^\n]+") do table.insert(lines, line) end - f:close() log:trace("Loaded scriptum scripts: " .. consul.inspect(lines)) @@ -3006,7 +3008,23 @@ consul.console.write( local index = string.sub(script_name, #ui.scriptum_entry + 1) consul.scriptum.entry = ui.scriptum_entry_text .. index - local success, err = pcall(dofile, script) + local success, err = pcall(function() + local script_file, open_err = consul.io_open(script, "rb") + if not script_file then + error(open_err or ("Could not open script: " .. script)) + end + + local script_content = script_file:read("*a") or "" + script_file:close() + script_content = script_content:gsub("\r\n", "\n"):gsub("\r", "\n") + + local chunk, load_err = loadstring(script_content, "@" .. script) + if not chunk then + error(load_err) + end + + return chunk() + end) -- Clean up after execution consul.scriptum.entry = nil