Re: os.execute is scary; Jay rants about strings again (was Re: [ANNOUNCE] lua stdlibs release: now Lua 5 compatible)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: os.execute is scary; Jay rants about strings again (was Re: [ANNOUNCE] lua stdlibs release: now Lua 5 compatible)
- From: Jay Carlson <nop@...>
- Date: 2004年1月31日 12:57:18 -0500
Reuben Thomas wrote:
On 2004年1月30日, Jay Carlson wrote:
On 2004年1月30日, Jay Carlson wrote:
On 2004年1月28日, Reuben Thomas wrote:
This is the main objection to what I propose above. What can't you do
conveniently with exec and glob?
Oh right, I forgot:
f = os.popen("mipsel-linux-objdump --syms --section="..section..
" --start-address="..hex(start).." "..objfilename)
for l in f:lines() do
_, _, etc = string.find(l, "^(%x%x%x%x%x%x%x%x) [^l] ...")
...
end
What's wrong with pipe, fork and exec? (With a simplifying wrapper,
obviously.)
To make things clearer, what I claim to want to write there is:
f = myos.popen("mipsel-linux-objdump", "--syms",
"--section="..section, "--start-address="..hex(start),
objfilename)
Right now, external libraries can't create file handles. So if I write
an external popen(argv, env), I have to duplicate the infrastructure in
liolib.c. The only way I can write myos.popen is in terms of the
existing io functions, building a complicated command line for io.popen.
Hey, Lua maintainers: this could be a fix for it:
liolib.c:
int
luaIO_filecreate(lua_State *L, FILE *f)
{
FILE **pf = newfile(L);
*pf = f;
return 1;
}
This also lets me easily write stuff like fdopen, which is not ANSI C,
but widely supported, even outside POSIX.
Jay