Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/uu/pwd/src/pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ const OPT_PHYSICAL: &str = "physical";

fn physical_path() -> io::Result<PathBuf> {
// 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()
}
}

Expand Down
Loading