From fa24c8c595f61dd3d63302ca18af86ee3ac97452 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 6 Aug 2025 15:07:36 +0800 Subject: [PATCH] hostname: *bsd: Collect lookup_host iterator into a vector dns_lookup 2.1.0 turns the output of lookup_host into an opaque iterator, collect it into a vector instead. And since we're at it, improve error handling instead of just unwrapping the result. --- src/uu/hostname/src/hostname.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 30522d637..558c6aff1 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -140,7 +140,9 @@ fn display_hostname(matches: &ArgMatches) -> UResult<()> { // use dns-lookup crate instead #[cfg(any(target_os = "freebsd", target_os = "openbsd"))] { - let addrs: Vec = lookup_host(hostname.as_str()).unwrap(); + let addrs: Vec = lookup_host(hostname.as_str()) + .map_err_context(|| "failed to lookup hostname".to_owned())? + .collect(); addresses = addrs; }