Check output device is a terminal: Difference between revisions
Check output device is a terminal (view source)
Revision as of 02:18, 19 December 2017
, 6 years agoAdded a solution for D
(Added section on PHP) |
(Added a solution for D) |
||
Line 85:
File.new("/dev/tty").tty? #=> true
STDOUT.tty? #=> true</lang>
=={{header|D}}==
<lang D>import std.stdio;
extern(C) int isatty(int);
void main() {
writeln("Stdout is tty: ", stdout.fileno.isatty == 1);
}</lang>
{{out}}
<pre>
prompt>a.out
Stdout is tty: true
prompt>a.out > out.txt
Stdout is tty: false
</pre>
=={{header|Factor}}==
|