Skip to content

Commit bca90ec

Browse files
committed
tr: replace rustix with filedescriptor for socketpair
1 parent f24d6aa commit bca90ec

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

‎.vscode/cspell.dictionaries/dependencies.wordlist.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ bstr
66
bytecount
77
byteorder
88
clap_mangen
9+
filedescriptor
910
foldhash
1011
hashbrown
1112
icu_datetime

‎Cargo.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ data-encoding-macro = "0.1.15"
6464
divan = { package = "codspeed-divan-compat", version = "5.0.0" }
6565
dns-lookup = { version = "4.0.0" }
6666
dunce = "1.0.4"
67+
filedescriptor = "0.8.3"
6768
filetime = "0.2.29"
6869
foldhash = "0.2.0"
6970
glob = "0.3.1"
@@ -395,6 +396,7 @@ runcon = { optional = true, version = "0.13.0", package = "uu_runcon", path = "s
395396
#pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`)
396397

397398
[target.'cfg(unix)'.dev-dependencies]
399+
filedescriptor = { workspace = true }
398400
nix = { workspace = true, features = ["fs", "signal"] }
399401
rustix = { workspace = true, features = ["net", "process"] }
400402

@@ -682,6 +684,9 @@ test = ["uu_test"]
682684
[lints]
683685
workspace = true
684686

687+
[patch.crates-io]
688+
filedescriptor = { git = "https://github.com/wezterm/wezterm.git", branch = "main" }
689+
685690
[[bin]]
686691
name = "coreutils"
687692
path = "src/bin/coreutils.rs"

‎tests/by-util/test_tr.rs‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,20 +1588,9 @@ fn test_broken_pipe_no_error() {
15881588
#[cfg(unix)]
15891589
#[test]
15901590
fn test_stdin_is_socket() {
1591-
use std::fs::File;
15921591
use std::io::Write as _;
15931592

1594-
let (mut writer, reader): (File, File) = {
1595-
rustix::net::socketpair(
1596-
rustix::net::AddressFamily::UNIX,
1597-
rustix::net::SocketType::STREAM,
1598-
rustix::net::SocketFlags::empty(),
1599-
None,
1600-
)
1601-
.map(|(fd0, fd1)| (fd0.into(), fd1.into()))
1602-
}
1603-
.unwrap();
1604-
1593+
let (mut writer, reader) = filedescriptor::socketpair().unwrap();
16051594
writer.write_all(b"::").unwrap();
16061595
drop(writer);
16071596

0 commit comments

Comments
 (0)