Skip to content

Commit 0c21cb9

Browse files
authored
tr: replace nix by rustix (#12266)
1 parent f4a0bb3 commit 0c21cb9

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/uucore/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jiff = { workspace = true, optional = true, features = [
3636
"tzdb-concatenated",
3737
] }
3838
rustc-hash = { workspace = true }
39-
rustix = { workspace = true, features = ["fs", "pipe", "process"] }
39+
rustix = { workspace = true, features = ["fs", "net", "pipe", "process"] }
4040
time = { workspace = true, optional = true, features = [
4141
"formatting",
4242
"local-offset",

tests/by-util/test_tr.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,20 +1649,19 @@ fn test_broken_pipe_no_error() {
16491649
.fails_silently();
16501650
}
16511651

1652-
#[cfg(not(windows))]
1652+
#[cfg(unix)]
16531653
#[test]
16541654
fn test_stdin_is_socket() {
1655-
use nix::sys::socket::{AddressFamily, SockFlag, SockType, socketpair};
1656-
use nix::unistd::write;
1655+
use std::io::Write as _;
16571656

1658-
let (fd1, fd2) = socketpair(
1659-
AddressFamily::Unix,
1660-
SockType::Stream,
1657+
let (fd1, fd2) = rustix::net::socketpair(
1658+
rustix::net::AddressFamily::UNIX,
1659+
rustix::net::SocketType::STREAM,
1660+
rustix::net::SocketFlags::empty(),
16611661
None,
1662-
SockFlag::empty(),
16631662
)
16641663
.unwrap();
1665-
write(fd1, b"::").unwrap();
1664+
std::fs::File::from(fd1).write_all(b"::").unwrap();
16661665
new_ucmd!()
16671666
.args(&[":", ";"])
16681667
.set_stdin(fd2)

0 commit comments

Comments
 (0)