Check output device is a terminal: Difference between revisions

m
m (Automated syntax highlighting fixup (second round - minor fixes))
m (→‎{{header|Wren}}: Minor tidy)
Line 637:
{{trans|C}}
As there is currently no way to obtain this information via Wren CLI, we instead embed a Wren script in a C application and ask the host program to get it for us.
<syntaxhighlight lang="ecmascriptwren">/* check_output_device_is_terminalCheck_output_device_is_terminal.wren */
 
class C {
Line 711:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "check_output_device_is_terminalCheck_output_device_is_terminal.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 731:
{{out}}
<pre>
$ ./Check_output_device_is_terminal
$ ./check_output_device_is_terminal
Output device is a terminal = true
 
$ ./check_output_device_is_terminalCheck_output_device_is_terminal > tmp
$ cat tmp
Output device is a terminal = false
 
$ ./check_output_device_is_terminalCheck_output_device_is_terminal | cat
Output device is a terminal = false
</pre>
 
=={{header|zkl}}==
On Unix, check to see if stdout's st_mode is a character device.
9,476

edits