Re: A curious issue with arg and dofile()
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: A curious issue with arg and dofile()
- From: steve donovan <steve.j.donovan@...>
- Date: 2010年10月12日 15:00:19 +0200
On Tue, Oct 12, 2010 at 2:54 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> local res,err = dofile(modpath)
> if not res then print(err) end
If you replace that with:
local f = io.open(modpath,'r')
local body = f:read '*a'
if body:find '^#!' then
local idx = body:find '\n'
body = body:sub(idx)
end
f:close()
local res,err = loadstring(body)
if not res then print(err) end
res()
then things work as expected, but notice the ugly/inefficient hack
needed to strip the hash-bang line that chokes loadstring...
steve d.