Check input device is a terminal: Difference between revisions

Content added Content deleted
m (replaced tty by terminal.)
Line 260: Line 260:
<lang Nim>import terminal
<lang Nim>import terminal


echo if stdin.isatty: "stdin is a tty" else: "stdin is not a tty"</lang>
echo if stdin.isatty: "stdin is a terminal" else: "stdin is not a terminal"</lang>


{{out}}
{{out}}
<pre>Command: ./check_input_dev
<pre>Command: ./check_input_dev
Result: stdin is a tty</pre>
Result: stdin is a terminal</pre>


<pre>Command: ./check_input_dev <somefile
<pre>Command: ./check_input_dev <somefile
Result: stdin is not a tty</pre>
Result: stdin is not a terminal</pre>


=={{header|OCaml}}==
=={{header|OCaml}}==