lua-users home
lua-l archive

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


On Fri, Nov 4, 2011 at 00:07, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> I want my program to print out a message when io.stdout is a terminal,
> but not when it is a disk file.  Current solution: write it to
> io.stderr, not io.stdout.  Is there a better way?
>
> Dirk
>
>

Common solutions include using stderr if stdout is likely not to be a
terminal, or providing an argument to write to a file instead of
stdout (instead of redirecting), or using isatty() to check. I recall
there being a way to check whether your code is running in the Lua
console by checking the call traceback or some such, but I don't think
that's what you mean by running interactively.

-- 
Sent from my toaster.