Luiz Berti
Luiz Berti

Reputation: 1491

Check if STDIN or STDOUT is a TTY in Lua

In C you have isatty(file_descriptor) and you can pass 0 as the file descriptor for STDIN and 1 for STDOUT.

How can I assert that in Lua?

Upvotes: 3

Views: 778

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80931

I don't know of anything built-in but you could always shell out for a test with [ or tty (obviously somewhat non-portable) if you didn't want to use a C module that exposed isatty.

C modules that expose isatty:

  1. lua-term
  2. luaposix

there are probably others too.

Upvotes: 2

Related Questions