-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
make ls work like dir on windows #6990
Conversation
@@ -352,6 +352,7 @@ fn should_skip_dir(dir: impl AsRef<Path>) -> bool { | |||
} | |||
|
|||
fn is_hidden_dir(metadata_attributes: u32) -> bool { | |||
#[cfg(windows)] |
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.
I'm guessing that this should be moved up so that is_hidden_dir
is only available on windows.
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.
Thanks!
Does this change always hide the directories? Or are they visible with the |
@rgwood |
@richardmarklund Looks like this has broken tests on Linux. Are you looking into that? |
@rgwood |
I see this is Windows-only, but what's the motivation for hiding symlinks? (other than emulating a Windows command) Edit Oh, is it simply that Windows doesn't allow symlinks? Ignore me if so! |
Windows does allow symlinks (but they're a little harder to create than on *nix). I think the logic needs to be more complex than "is it a symlink?" because cmd.exe and PowerShell do show some symlinks. However, Nu shows a few symlinks that don't show up in cmd.exe and PowerShell: I'm not sure what exactly differentiates those symlinks from the ones shown by cmd.exe and PowerShell. symlinks in cmd.exe dirsymlinks in PowerShell ls |
They have the system attribute (as well as having the hidden attribute). In powershell try |
@rgwood @ChrisDenton So here I'm filtering out everything that's either system or hidden according to: But if I also remove the symlinks it seems like its correct: |
I also have a question: command: The next test: lists_all_hidden_files_when_glob_does_not_contain_dot The test wants that to return 5, which I find a bit strange. My returns 7 which also feels strange. My intuition wanted it to be 11. But I guess the command is run inside Anyways, how do you want this to work? My thought was that if you specify a glob pattern then you want all the results regardless of if the command is with a dot or not. We could either go the route of if you are specifying a glob pattern and then give the full result or you'll have to add What's your thought? |
Sorry, I'm not very familiar with the code. How are you getting the attributes? The relevant attributes are on the symlink. If you have a |
@richardmarklund See my examples here; cmd.exe and pwsh do not hide all symlinks by default. |
Alternatively, why not just create a switch to opt into os-specific behavior (ie, |
@richardmarklund Thanks for your work on this :). It seems like this PR has stalled so I'm going to close it for now, but if you want to pick it up again we can always reopen it. |
Description
Related issue: #6857
This fix makes the ls command work like dir on windows. This hides more files like symfiles and other dirs that the dir command does not show.
Could not create any new tests since we have a strange way to create hidden files (by creating dotfiles) and could not find any way to create symlinks.
Tests + Formatting
Make sure you've done the following, if applicable:
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace --features=extra
to check that all tests passUser-Facing Changes
If you're making changes that will affect the user experience of Nushell (ex: adding/removing a command, changing an input/output type, adding a new flag):