lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have an interesting problem involving one of my projects on Unix.

The reasons why are complicated, but my project boils down to needing to run a 
Lua script, passed in on stdin, while giving the script arguments. According 
to the documentation, this should work:

cat script.lua | lua - -- argument1 argument2 argument3

However, what actually happens is that script.lua gets executed with arg as 
nil, and then when it terminates, the interpreter tries to load argument1 and 
fails.

Looking at lua.c, I see that the handle_argv() function only builds the arg 
table *after* it's finished processing all the options. Because - is 
considered an option, any script that gets executed as part of its execution 
doesn't get any arguments...

On Linux I can work around this by using /dev/stdin as an input filename, and 
for now I'm going to hack my version of lua.c so that this will work on other 
systems, but I reckon this is at least a bug --- definitely a misfeature.

-- 
+- David Given --McQ-+ "...it's not that well-designed GUI's are rare,
|  dg@cowlark.com    | it's just that the three-armed users GUI's are
| (dg@tao-group.com) | designed for are rare." --- Mike Uhl on a.f.c
+- www.cowlark.com --+ 

Attachment: pgpehRKRbpNdu.pgp
Description: PGP signature