lua-users home
lua-l archive

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

or you could redefine error() to write to stdout in Lua:
local error = function (...)
   print (...)
   --stack traceback and exit, or something
this would be the portable solution.


From: on behalf of David Given
Sent: Tue 12/20/2005 10:59 AM
To: Lua list
Subject: Re: Joining stdout and stderr

On Tuesday 20 December 2005 15:55, Eduardo Ochs wrote:
> error("Bla!")

Ah --- didn't realise you were using error(). The default implementation
which, if I've managed to find it correctly is in lua.c, explicitly writes to
stderr. It doesn't go through the Lua I/O layer.

I'd say you probably have three choices:

(a) do something OS specific which I don't know about.
(b) patch lua.c to write to stdout instead of stderr.
(c) change your script to execute all code inside a pcall wrapper, so that you
can provide your own error reporter that writes to stdout.

Assuming Windows is reasonably Posix, it *may* be possible to simply tell it
to line buffer stdout and stderr --- this will normally do what you want.
setlinebuf() should do this. I don't know if this works on Windows, though.

+- David Given --McQ-+ "In America, family has become a code word for
|    | something that you can put a five-year-old in front
| ( | of and come back secure in the knowledge that your
+- --+ child not will not have been exposed to any ideas."