-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement physical and logical cwd #219
base: main
Are you sure you want to change the base?
Conversation
9262eb8
to
88cbdb7
Compare
Performance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
Thanks for diving deep into this; I'll need a bit of time to review the changes here. Is there a reasonable way to break this up into multiple, smaller changes? |
I don't think so, maybe All changes are based on the new
For startup cwd Inside In other changed files, such as dirs or interp, I fixed the usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 17 changed files in this pull request and generated no comments.
Files not reviewed (11)
- brush-shell/tests/completion_tests.rs: Evaluated as low risk
- brush-shell/tests/cases/builtins/pwd.yaml: Evaluated as low risk
- brush-core/src/patterns.rs: Evaluated as low risk
- brush-core/src/prompt.rs: Evaluated as low risk
- brush-interactive/src/completion.rs: Evaluated as low risk
- brush-core/src/interp.rs: Evaluated as low risk
- brush-core/src/builtins/cd.rs: Evaluated as low risk
- brush-core/src/commands.rs: Evaluated as low risk
- brush-core/src/builtins/pushd.rs: Evaluated as low risk
- brush-core/src/completion.rs: Evaluated as low risk
- brush-core/src/builtins/popd.rs: Evaluated as low risk
Comments suppressed due to low confidence (3)
brush-core/src/builtins/pwd.rs:9
- [nitpick] The variable name 'physical' is ambiguous. It should be renamed to 'print_physical_directory'.
#[arg(short = 'P', overrides_with = "allow_symlinks")]
brush-core/src/builtins/pwd.rs:13
- [nitpick] The variable name 'allow_symlinks' is ambiguous. It should be renamed to 'print_logical_directory'.
#[arg(short = 'L', overrides_with = "physical")]
brush-core/src/builtins/pwd.rs:36
- The error message for unimplemented flags should be clear and helpful. Consider updating it to 'Error: The -P and -L flags are not yet implemented.'
writeln!(context.stdout(), "{}", cwd.display())?;
My apologies for having put this on hold for so long, @39555 --thanks again for putting so much hard work into this and being patient while we addressed other areas of the project. We've since cleared out a number of the most commonly hit gaps in I recall you mentioning in another issue that you may not have bandwidth for contributions right now. Is that the case? If so, would you be open to me helping rebase this against latest changes and shepherd it through? I'm also okay waiting if you'd prefer to come back to this yourself at some point in the future. |
Hi @reubeno ! Yes it would be great if you could help me finalize this feature. Big thanks! |
After diving into the system's paths rabbit hole for a while, I've implemented cross-platform
cwd
handling for the shell, along with support forcd -L -P
andpwd -L -P
.Closes: #202
With this PR, the shell now maintains the logical current working directory alongside with the physical one. To correctly create an absolute path and expand all
..
and.
from the logical path, the functions have been added to thebrush_core::sys::fs
crate:expand_tilde_with_home
- expands the tilde using the givenhome
directorymake_absolute
- makes the path absolute based on the givenbase
path.normalize_lexically
- performs canonicalization without touching the filesystem.Posix notes:
There is a special handling for paths with double slashes, such as
//users/home
See: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
Windows notes
There is a lot of special handling for Windows weird path formats:
\\server\share\my_dir
.\\?\C$\super_path
, this paths must not be normalized.\\.\Pipe
and UNC with the device namespace\\.\UNC\
.C:iamrelative
.See: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
See: The book of windows file path: https://chrisdenton.github.io/omnipath/
I've written a lot of tests, trying to cover all the special cases.