From b1d60bb06a493b1bd02ea4f02ec7b3656063dba3 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 28 Oct 2024 23:30:04 +1000 Subject: Various minor tweaks and cleanups. --- .test_.conf.lua | 4 ++-- PolygLua.lua | 10 +++++----- test_.lua | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.test_.conf.lua b/.test_.conf.lua index e35fc72..1bd73c1 100644 --- a/.test_.conf.lua +++ b/.test_.conf.lua @@ -1,8 +1,8 @@ -- This works coz LuaJIT automatically loads the jit module. if type(jit) == 'table' then - io.write(arg[0] .. ' is being run by ' .. jit.version .. ' under ' .. jit.os .. ' on a ' .. jit.arch .. '\n') + print(arg[0] .. ' is being run by ' .. jit.version .. ' under ' .. jit.os .. ' on a ' .. jit.arch .. '. Lua version ' .. _VERSION) else - io.write(arg[0] .. ' is being run by Lua version ' .. _VERSION .. '\n') + print(arg[0] .. ' is being run by Lua version ' .. _VERSION) end return { diff --git a/PolygLua.lua b/PolygLua.lua index 20925b7..8d63d8a 100755 --- a/PolygLua.lua +++ b/PolygLua.lua @@ -106,7 +106,7 @@ _.parse = function(args, options, confFile) if nil ~= confFile then for i,v in ipairs{'/etc/', '~/.', './.'} do local p = v .. confFile .. '.conf.lua' - local h, e = io.open(p, 'r') + local h = io.open(p, 'r') if nil ~= h then D('Found configuration file '.. p) h:close() @@ -124,9 +124,9 @@ _.parse = function(args, options, confFile) local ds = 0 if ('-' == a:sub(1, 1)) and ('-' ~= a:sub(2, 2)) then ds = 1 end if '--' == a:sub(1, 2) then ds = 2; a = a:sub(3, -1) end - local s, e = a:find('=') + local s, e = a:find('=', 1, true) local k , v - if nil == s then + if not s then e = 0 v = nil else @@ -158,7 +158,7 @@ _.running = function(c) end _.exists = function(f) - local h, e = io.open(f, 'r') + local h = io.open(f, 'r') if nil == h then return false else h:close(); return true end end @@ -222,7 +222,7 @@ _G.__ = function(c) end if exe.isScript then local a, e = io.open(exe.scriptFile, 'w') - if nil == a then E('Could not open ' .. exe.scriptFile) else + if nil == a then E('Could not open ' .. exe.scriptFile .. ' - ' .. e) else a:write(exe.script) a:close() end diff --git a/test_.lua b/test_.lua index 1a892a9..872bea7 100755 --- a/test_.lua +++ b/test_.lua @@ -1,5 +1,11 @@ #!/usr/bin/env luajit +if type(jit) == 'table' then + print(arg[0] .. ' is being run by ' .. jit.version .. ' under ' .. jit.os .. ' on a ' .. jit.arch .. '. Lua version ' .. _VERSION) +else + print(arg[0] .. ' is being run by Lua version ' .. _VERSION) +end + local _ = require 'PolygLua' @@ -159,3 +165,4 @@ __'date':log():show():Do() -- Should get that "later" thing printed while the sleep is happening. __'date; sleep 5; date':log():show():Do() + -- cgit v1.1