summaryrefslogtreecommitdiff
path: root/runtime/ops/tty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops/tty.rs')
-rw-r--r--runtime/ops/tty.rs41
1 files changed, 20 insertions, 21 deletions
diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs
index 390f948dc..45d458b79 100644
--- a/runtime/ops/tty.rs
+++ b/runtime/ops/tty.rs
@@ -225,27 +225,26 @@ fn op_isatty(
) -> Result<Value, AnyError> {
let rid = args.rid;
- let isatty: bool =
- StdFileResource::with(state, rid as u32, move |r| match r {
- Ok(std_file) => {
- #[cfg(windows)]
- {
- use winapi::um::consoleapi;
-
- let handle = get_windows_handle(&std_file)?;
- let mut test_mode: DWORD = 0;
- // If I cannot get mode out of console, it is not a console.
- Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
- }
- #[cfg(unix)]
- {
- use std::os::unix::io::AsRawFd;
- let raw_fd = std_file.as_raw_fd();
- Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
- }
+ let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
+ Ok(std_file) => {
+ #[cfg(windows)]
+ {
+ use winapi::um::consoleapi;
+
+ let handle = get_windows_handle(&std_file)?;
+ let mut test_mode: DWORD = 0;
+ // If I cannot get mode out of console, it is not a console.
+ Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
}
- _ => Ok(false),
- })?;
+ #[cfg(unix)]
+ {
+ use std::os::unix::io::AsRawFd;
+ let raw_fd = std_file.as_raw_fd();
+ Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
+ }
+ }
+ _ => Ok(false),
+ })?;
Ok(json!(isatty))
}
@@ -269,7 +268,7 @@ fn op_console_size(
let rid = args.rid;
- let size = StdFileResource::with(state, rid as u32, move |r| match r {
+ let size = StdFileResource::with(state, rid, move |r| match r {
Ok(std_file) => {
#[cfg(windows)]
{