Use is-terminal instead of atty.
Following up on #3696, use the new is-terminal crate to test for a tty rather than having platform-specific logic in Wasmtime. The is-terminal crate has a platform-independent API which takes a handle. This also updates the tree to cap-std 0.24 etc., to avoid depending on multiple versions of io-lifetimes at once, as enforced by the cargo deny check.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use cap_fs_ext::MetadataExt;
|
||||
use fs_set_times::{SetTimes, SystemTimeSpec};
|
||||
use is_terminal::IsTerminal;
|
||||
use std::any::Any;
|
||||
use std::convert::TryInto;
|
||||
use std::io;
|
||||
@@ -125,14 +126,7 @@ impl WasiFile for File {
|
||||
Ok(self.0.num_ready_bytes()?)
|
||||
}
|
||||
fn isatty(&self) -> bool {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
rustix::io::isatty(&self.0)
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
false
|
||||
}
|
||||
self.0.is_terminal()
|
||||
}
|
||||
async fn readable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::file::convert_systimespec;
|
||||
use fs_set_times::SetTimes;
|
||||
use io_lifetimes::AsFilelike;
|
||||
use is_terminal::IsTerminal;
|
||||
use std::any::Any;
|
||||
use std::convert::TryInto;
|
||||
use std::fs::File;
|
||||
@@ -111,14 +112,7 @@ impl WasiFile for Stdin {
|
||||
Ok(self.0.num_ready_bytes()?)
|
||||
}
|
||||
fn isatty(&self) -> bool {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
rustix::io::isatty(&self.0)
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
atty::is(atty::Stream::Stdin)
|
||||
}
|
||||
self.0.is_terminal()
|
||||
}
|
||||
async fn readable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
@@ -242,14 +236,7 @@ macro_rules! wasi_file_write_impl {
|
||||
Ok(0)
|
||||
}
|
||||
fn isatty(&self) -> bool {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
rustix::io::isatty(&self.0)
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
atty::is(atty::Stream::$ident)
|
||||
}
|
||||
self.0.is_terminal()
|
||||
}
|
||||
async fn readable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
|
||||
Reference in New Issue
Block a user