[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [Q] print function and stdout redirection?
- From: "Leo Razoumov" <slonik.az@...>
- Date: Tue, 16 Oct 2007 08:48:20 -0400
Hi All,
I am a bit surpprised that redirecting stdout to a file by means of
io.output(file) has no effect on print(...) function. For example,
executing the following code snippet with Lua-5.1.2 on Ubuntu-7.4
linux
io.output("/tmp/tmp.log")
print(1,2,3,4,5)
leaves the file /tmp/tmp.log empty and a sting of output goes to the
terminal screen (default stdout) instead. Quick look at "luaB_print"
function (file: src/lbaselib.c) reveals that it uses "stdout" as
defined in #include<stdio.h> and it seems that it cannot be changed
from within the Lua itself.
Am I missing something? Is it a bug or an intended behavior?
Unlike "print" io.write behaves as expected.
Thanks,
--Leo--