From aff71abdc41e3d3bf59f66b7a7f7b6be3985a28e Mon Sep 17 00:00:00 2001 From: Amirhossein Ghanipour Date: Tue, 29 Jul 2025 07:01:04 +0330 Subject: [PATCH] style(pwd): simplify physical_path implementation --- src/uu/pwd/src/pwd.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index 5abe5aae0..55d4927fb 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -19,19 +19,20 @@ const OPT_PHYSICAL: &str = "physical"; fn physical_path() -> io::Result { // std::env::current_dir() is a thin wrapper around libc::getcwd(). + let path = env::current_dir()?; // On Unix, getcwd() must return the physical path: // https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html #[cfg(unix)] { - env::current_dir() + Ok(path) } // On Windows we have to resolve it. // On other systems we also resolve it, just in case. #[cfg(not(unix))] { - env::current_dir().and_then(|path| path.canonicalize()) + path.canonicalize() } }