Skip to content

Commit 1107d72

Browse files
sylvestreoech3
authored andcommitted
tty: replace nix by rustix
1 parent 41570b7 commit 1107d72

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/tty/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ uucore = { workspace = true, features = ["fs"] }
2424
fluent = { workspace = true }
2525

2626
[target.'cfg(unix)'.dependencies]
27-
nix = { workspace = true, features = ["term"] }
27+
rustix = { workspace = true, features = ["fs", "termios"] }
2828

2929
[[bin]]
3030
name = "tty"

src/uu/tty/src/tty.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
3939

4040
let mut stdout = std::io::stdout();
4141

42-
let name = nix::unistd::ttyname(std::io::stdin());
42+
let name = rustix::termios::ttyname(std::io::stdin(), Vec::with_capacity(8));
4343

4444
let write_result = if let Ok(name) = name {
45-
stdout.write_all_os(name.as_os_str())
45+
use std::os::unix::ffi::OsStrExt;
46+
let os_name = std::ffi::OsStr::from_bytes(name.as_bytes());
47+
stdout.write_all_os(os_name)
4648
} else {
4749
set_exit_code(1);
4850
writeln!(stdout, "{}", translate!("tty-not-a-tty"))

0 commit comments

Comments
 (0)