Check input device is a terminal: Difference between revisions
Content added Content deleted
No edit summary |
(Dialects of BASIC moved to the BASIC section.) |
||
Line 35: | Line 35: | ||
stdin is not a tty. |
stdin is not a tty. |
||
</pre> |
</pre> |
||
⚫ | |||
=={{header|BASIC}}== |
|||
⚫ | |||
<syntaxhighlight lang="freebasic">terminal = isatty(0) |
<syntaxhighlight lang="freebasic">terminal = isatty(0) |
||
PRINT terminal</syntaxhighlight> |
PRINT terminal</syntaxhighlight> |
||
Line 49: | Line 51: | ||
prompt$ ./istty <<<"testing" |
prompt$ ./istty <<<"testing" |
||
0</pre> |
0</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|C}}== |
=={{header|C}}== |
||
Use <code>isatty()</code> on file descriptor to determine if it's a TTY. To get the file descriptor from a <code>FILE*</code> pointer, use <code>fileno</code>: |
Use <code>isatty()</code> on file descriptor to determine if it's a TTY. To get the file descriptor from a <code>FILE*</code> pointer, use <code>fileno</code>: |
||
Line 153: | Line 189: | ||
C:\test < in.txt |
C:\test < in.txt |
||
Input doesn't come from tty.</pre> |
Input doesn't come from tty.</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Go}}== |
=={{header|Go}}== |