[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: print() and the interactive prompt
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 13 Jul 2011 21:51:38 -0300
> Use debug.getinfo to see if your replacement print function is being called
> from the first function on the call stack (the interpreter). It would look
> like:
>
> if debug.getinfo(3) == nil then
> -- interpreter
> else
> -- normal
> end
lua.c runs lines entered interactively using this:
status = luaL_loadbuffer(L, line, l, "=stdin");
So you can check whether the source is "=stdin":
print(debug.getinfo(1).source)
Ah, "=stdin" is also used by luaL_loadfile(L,NULL), but I think this is
rarely used.