Skip to content

pwd: explain failures when the working directory was removed - #15494

Merged
sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/pwd-deleted-directory-error-12967
Oct 19, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/pwd-deleted-directory-error-12967

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

On Unix, report the missing directory entry when getcwd fails with ENOENT. Other failures retain their existing error context.

Extend regression coverage to a deleted working directory replaced by a regular file, with both -L and -P. All 15 pwd integration tests pass.

Closes #12967.

@limadog9
limadog9 force-pushed the fix/pwd-deleted-directory-error-12967 branch from 9e62034 to 7ec4fed Compare October 18, 2026 19:46
@sylvestre

Copy link
Copy Markdown
Contributor

nearly there, mostly the test duplication to fix

Comment thread src/uu/pwd/src/pwd.rs Outdated
physical_path()
}
.map_err_context(|| translate!("pwd-error-failed-to-get-current-directory"))?;
.or_else(|error| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the early return under #[cfg(unix)] inside the closure is a bit hard to read, could it be a simple match?

Comment thread tests/by-util/test_pwd.rs Outdated
wasi_runner,
ignore = "WASI sandbox: requires a host shell and a deleted cwd"
)]
fn test_cwd_replaced_with_file() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is almost the same as test_deleted_dir, could you please merge them? (add the file + the -L/-P loop there)

On Unix, report the missing directory entry when getcwd fails with ENOENT. Other failures retain their existing error context.

Extend regression coverage to a deleted working directory replaced by a regular file, with both -L and -P. All 15 pwd integration tests pass.

Closes uutils#12967.
@limadog9
limadog9 force-pushed the fix/pwd-deleted-directory-error-12967 branch from 7ec4fed to 9ce625d Compare October 18, 2026 22:31
@sylvestre
sylvestre merged commit ad334f0 into uutils:main Oct 19, 2026
100 of 101 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minorbug(pwd): when the current cwd swapped to be a normal file it returns vague error messages

2 participants