[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Standalone lua, stdin, and arguments
- From: David Burgess <dburgess@...>
- Date: Wed, 12 Oct 2005 08:04:23 +1000
I agree that it is a bug. The same problem occurs with
lua - -e print(arg) -- "arg1" or
lua - -e print(...) -- "arg1"
What is your suggested solution?
On 10/12/05, David Given <firstname.lastname@example.org> wrote:
> 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
> 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,
> | email@example.com | it's just that the three-armed users GUI's are
> | (firstname.lastname@example.org) | designed for are rare." --- Mike Uhl on a.f.c
> +- www.cowlark.com --+