RosettaCodeData/Task/Check-output-device-is-a-terminal/Lua/check-output-device-is-a-terminal-2.lua
2023-07-01 13:44:08 -04:00

11 lines
272 B
Lua

local unistd = require( "posix.unistd" )
local function isTTY ( fd )
fd = tonumber( fd ) or 1
local ok, err, errno = unistd.isatty( fd )
return ok and true or false
end
print( "stdin", isTTY( 0 ) )
print( "stdout", isTTY( 1 ) )
print( "stderr", isTTY( 2 ) )