Jump to content

Check output device is a terminal: Difference between revisions

m (moved Categorys to top / Category:Hardware)
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>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.