Check input device is a terminal: Difference between revisions
Content added Content deleted
m (moved Categorys to top / Category:Hardware) |
(→{{header|UNIX Shell}}: Added zkl) |
||
Line 231: | Line 231: | ||
echo "Input is NOT a terminal" |
echo "Input is NOT a terminal" |
||
fi</lang> |
fi</lang> |
||
=={{header|zkl}}== |
|||
On Unix, check to see if stdin'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.stdin).println();</lang> |
|||
{{out}} |
|||
<pre> |
|||
$ zkl bbb # from the command line |
|||
True |
|||
$ zkl bbb < bbb.zkl |
|||
False |
|||
$ cat bbb.zkl | zkl bbb |
|||
False |
|||
</pre> |