diff options
| author | Saikari <[email protected]> | 2026-02-02 10:28:45 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-02 10:28:45 +0300 |
| commit | d1653c5b32f4efa7fec6ab40cb93eb14b0014c38 (patch) | |
| tree | 0f9edaac965debf5f3b97fa22216b5e74982635e /xmake/plugins/lua | |
| parent | f851d28b49caa6d19e4edc1df39b74222bda6946 (diff) | |
refactor: enhance stdin script handling by improving string trimming logic
Diffstat (limited to 'xmake/plugins/lua')
| -rw-r--r-- | xmake/plugins/lua/main.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/xmake/plugins/lua/main.lua b/xmake/plugins/lua/main.lua index 261dffaa0..b2a104949 100644 --- a/xmake/plugins/lua/main.lua +++ b/xmake/plugins/lua/main.lua @@ -53,9 +53,14 @@ function _get_script_from_stdin() script_content = script_content:ltrim(utf8.bom) local shell = os.shell() if shell == "cmd" or shell == "powershell" or shell == "pwsh" or is_host("windows") then - script_content = script_content:trim() - script_content = script_content:trim('\"') - script_content = script_content:replace("\\n", "\n", {plain = true}):replace("\\r", "\r", {plain = true}) + local trimmed = script_content:trim() + if trimmed:startswith('"') and trimmed:endswith('"') then + script_content = trimmed:trim('"') + script_content = script_content:replace("\\n", "\n", {plain = true}) + :replace("\\r", "\r", {plain = true}) + else + script_content = trimmed + end end if not script_content:find("function main", 1, true) then |
