Check input device is a terminal: Difference between revisions
Check input device is a terminal (view source)
Revision as of 10:47, 17 November 2023
, 6 months ago→{{header|Wren}}: Changed to Wren S/H
mNo edit summary |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(One intermediate revision by one other user not shown) | |||
Line 172:
C:\test < in.txt
Input doesn't come from tty.</pre>
=={{header|Forth}}==
{{works with|gforth|0.7.3}}
In Gforth, the word "source-id" is used to determine the program source.
If you got a program file "source.f":
<syntaxhighlight lang="Forth">
: ?tty source-id if ." not " then ." from terminal" ; ?tty bye
</syntaxhighlight>
Then,
<syntaxhighlight lang="bash">gforth source.f</syntaxhighlight> in the shell will display:
{{out}}<pre>not from terminal</pre>
Then,
<syntaxhighlight lang="bash">gforth -e ': ?tty source-id if ." not " then ." from terminal" ; ?tty bye'</syntaxhighlight> will display:
{{out}}<pre>not from terminal</pre>
At Gforth prompt,
<syntaxhighlight lang="bash">: ?tty source-id if ." not " then ." from terminal" ; ?tty bye</syntaxhighlight> will display:
{{out}}<pre>from terminal</pre>
=={{header|FutureBasic}}==
Line 498 ⟶ 519:
=={{header|Wren}}==
<syntaxhighlight lang="
System.print("Input device is a terminal? %(Stdin.isTerminal ? "Yes" : "No")")</syntaxhighlight>
Line 506 ⟶ 527:
Input device is a terminal? Yes
</pre>
=={{header|zkl}}==
On Unix, check to see if stdin's st_mode is a character device.
|