Check output device is a terminal: Difference between revisions

Content added Content deleted
m (moved Categorys to top / Category:Hardware)
Line 242: Line 242:
echo "Output is NOT a terminal" >/dev/tty
echo "Output is NOT a terminal" >/dev/tty
fi</lang>
fi</lang>

=={{header|zkl}}==
On Unix, check to see if stdout's st_mode is a character device.
<lang zkl>const S_IFCHR=0x2000;
fcn S_ISCHR(f){ f.info()[4].bitAnd(S_IFCHR).toBool() }
S_ISCHR(File.stdout).println();</lang>
{{out}}
<pre>
$ zkl bbb # from the command line
True
$ zkl bbb | more
False
$ zkl bbb > foo.txt
$ cat foo.txt
False
</pre>