Anonymous user
Check output device is a terminal: Difference between revisions
→{{header|UNIX Shell}}: Added zkl
m (moved Categorys to top / Category:Hardware) |
(→{{header|UNIX Shell}}: Added zkl) |
||
Line 242:
echo "Output is NOT a terminal" >/dev/tty
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>
|