lua-users home
lua-l archive

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


> 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.