Check output device is a terminal: Difference between revisions

Content added Content deleted
(J)
(→‎{{header|Rust}}: Updated to the Rust 1.2.0)
Line 235: Line 235:
</lang>
</lang>
=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>/* Rust 0.9 version. Uses C library interface */
<lang rust>/* Uses C library interface */

extern mod std;
use std::libc;
extern crate libc;


fn main() {
fn main() {
let istty = unsafe { libc::isatty(libc::STDOUT_FILENO as i32) } != 0;
let istty = unsafe { libc::isatty(libc::STDOUT_FILENO as i32) } != 0;
if (istty) {
if istty {
println("stdout is tty");
println!("stdout is tty");
} else {
} else {
println("stdout is not tty");
println!("stdout is not tty");
}
}
}</lang>
}</lang>