# isatty

Definition: | bool res = isatty(integer fn)
Description: | Check whether stdin/stdout/stderr have been redirected. fn: 0/1/2 for stdin/stdout/stderr respectively. Returns true if the specified device is connected to a terminal, false if it has been redirected.
pwa/p2js: | Not supported
Comments: | You may, for instance, wish to output much more detailed results to a file than the console, or use a much less human-readable format when the recipient is likely to be another program.
Example: |
    printf(1,"stdin:%t, stdout:%t, stderr:%t\n",{isatty(0),isatty(1),isatty(2)})
    --
    -- p test                               ==> stdin:true, stdout:true, stderr:true
    --
    -- echo hello | p test                  ==> stdin:false, stdout:true, stderr:true
    --
    -- p test > test.txt; type test.txt     ==> stdin:true, stdout:false, stderr:true
    --
    -- p test 2> test.txt                   ==> stdin:true, stdout:true, stderr:false
Implementation: | See builtins\isatty.e (an autoinclude) for details of the actual implementation.
Technicalia | If you redirect stdin, as per "echo hello" above, and then use `{}=wait_key()` or similar, you may need to use Ctrl C to terminate the program. Obviously you can/are expected to avoid that sort of thing by using `if isatty(0) then {}=wait_key() end if` instead. I may one day modify maybe_any_key() to use this routine, however that would obviously make it inconsistent with the exceedingly stupid and horrible behaviour of the Euphoria version...