[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua.c & path setup
- From: David Given <dg@...>
- Date: Tue, 30 Nov 2004 16:47:52 +0000
On Tuesday 30 November 2004 16:05, Roberto Ierusalimschy wrote:
> > Does anyone know why the lua.c command line interpreter is set up
> > to call do_path (which sets up the plugin loading paths) *after* it
> > executes the script you tell it to?
>
> What do you mean by "do_path"?
There's a static function called do_path() in lua.c whose job is to initialise
the LUA_PATH global variable. It's called from a number of places. pmain(),
which is the main part of the program, does this:
static int pmain (lua_State *l) {
[...]
lua_userinit(l); /* open libraries */
status = handle_luainit();
if (status == 0) {
status = handle_argv(s->argv, &interactive);
do_path();
if (status == 0 && interactive) manual_input();
}
[...]
return 0;
}
handle_luainit() is the routine that looks at the LUA_INIT environment
variable and runs the script named there.
So, the order of things is: register the hard-coded libraries; run LUA_INIT;
run any scripts on the command line; set up LUA_PATH; enter interactive mode.
This seems strange. I'd have expected do_path() to go right up the top,
before LUA_INIT.
--
+- David Given --McQ-+ "What appears to be a sloppy or meaningless use of
| dg@cowlark.com | words may well be a completely correct use of words
| (dg@tao-group.com) | to express sloppy or meaningless ideas." ---
+- www.cowlark.com --+ Anonymous Diplomat