From df258cd307af2da8c9984642b79be9a69d86016d Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 13 May 2026 13:47:04 +0100 Subject: [PATCH] tr: replace rustix with filedescriptor for socketpair --- Cargo.lock | 4 ++-- Cargo.toml | 7 ++++++- tests/by-util/test_tr.rs | 14 +++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3df2d707b3..33aac7e192 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,6 +548,7 @@ dependencies = [ "clap_complete", "clap_mangen", "ctor", + "filedescriptor", "filetime", "fluent-syntax", "glob", @@ -1033,8 +1034,7 @@ checksum = "31a7a908b8f32538a2143e59a6e4e2508988832d5d4d6f7c156b3cbc762643a5" [[package]] name = "filedescriptor" version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" +source = "git+https://github.com/wezterm/wezterm.git?rev=21ad43049bf1f03469fb1e00447c91cdf15d1e98#21ad43049bf1f03469fb1e00447c91cdf15d1e98" dependencies = [ "libc", "thiserror 1.0.69", diff --git a/Cargo.toml b/Cargo.toml index fa9543d607..350b725870 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ # coreutils (uutils) # * see the repository LICENSE, README, and CONTRIBUTING files for more information -# spell-checker:ignore (libs) bigdecimal datetime foldhash serde gethostid kqueue libcrypto libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner getauxval +# spell-checker:ignore (libs) bigdecimal datetime filedescriptor foldhash serde gethostid kqueue libcrypto libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner getauxval [package] name = "coreutils" @@ -418,6 +418,7 @@ dns-lookup = { version = "3.0.0" } dunce = "1.0.4" exacl = "0.13.0" file_diff = "1.0.0" +filedescriptor = "0.8.3" filetime = "0.2.29" foldhash = "0.2.0" fs_extra = "1.3.0" @@ -575,6 +576,7 @@ ignored = ["clap", "fluent", "libstdbuf"] clap.workspace = true clap_complete = { workspace = true, optional = true } clap_mangen = { workspace = true, optional = true } +filedescriptor.workspace = true fluent-syntax = { workspace = true, optional = true } itertools.workspace = true jiff = { workspace = true, optional = true } @@ -753,6 +755,9 @@ phf_codegen.workspace = true [lints] workspace = true +[patch.crates-io] +filedescriptor = { git = "https://github.com/wezterm/wezterm.git", rev = "21ad43049bf1f03469fb1e00447c91cdf15d1e98" } + [[bin]] name = "coreutils" path = "src/bin/coreutils.rs" diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 642af8aab6..6be3caeb37 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -1655,17 +1655,13 @@ fn test_broken_pipe_no_error() { fn test_stdin_is_socket() { use std::io::Write as _; - let (fd1, fd2) = rustix::net::socketpair( - rustix::net::AddressFamily::UNIX, - rustix::net::SocketType::STREAM, - rustix::net::SocketFlags::empty(), - None, - ) - .unwrap(); - std::fs::File::from(fd1).write_all(b"::").unwrap(); + let (mut writer, reader) = filedescriptor::socketpair().unwrap(); + writer.write_all(b"::").unwrap(); + drop(writer); + new_ucmd!() .args(&[":", ";"]) - .set_stdin(fd2) + .set_stdin(reader) .succeeds() .stdout_is(";;"); }