diff --git a/Cargo.lock b/Cargo.lock index c0b7cb3b3b1..2077096f441 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4349,7 +4349,7 @@ version = "0.8.0" dependencies = [ "clap", "fluent", - "nix", + "rustix", "uucore", ] diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index fe5a97b07e7..6fe03e42525 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -24,7 +24,7 @@ uucore = { workspace = true, features = ["fs"] } fluent = { workspace = true } [target.'cfg(unix)'.dependencies] -nix = { workspace = true, features = ["term"] } +rustix = { workspace = true, features = ["fs", "termios"] } [[bin]] name = "tty" diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index cb5ae8e1721..3dfef73225e 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -39,10 +39,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut stdout = std::io::stdout(); - let name = nix::unistd::ttyname(std::io::stdin()); + let name = rustix::termios::ttyname(std::io::stdin(), Vec::with_capacity(8)); let write_result = if let Ok(name) = name { - stdout.write_all_os(name.as_os_str()) + use std::os::unix::ffi::OsStrExt; + let os_name = std::ffi::OsStr::from_bytes(name.as_bytes()); + stdout.write_all_os(os_name) } else { set_exit_code(1); writeln!(stdout, "{}", translate!("tty-not-a-tty"))