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>/* |
<lang rust>/* Uses C library interface */ |
||
extern mod std; |
|||
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 |
if istty { |
||
println("stdout is tty"); |
println!("stdout is tty"); |
||
} else { |
} else { |
||
println("stdout is not tty"); |
println!("stdout is not tty"); |
||
} |
} |
||
}</lang> |
}</lang> |