[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Standalone lua, stdin, and arguments
- From: David Burgess <dburgess@...>
- Date: Wed, 12 Oct 2005 08:20:18 +1000
In lua 5.1, while we are looking at lua.c and args
I think the creation of the "arg" variable should be guarded with
#ifdef LUA_COMPAT_VARARG
On 10/12/05, David Burgess <dburgess@gmail.com> wrote:
> 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?
>
> DB
> On 10/12/05, David Given <dg@cowlark.com> 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
> > 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 --+
> >
> >
> >
> >
>