Open NotTheDr01ds opened 3 months ago
A git bisect would be helpful to figure out what PR broke this functionality.
There is no sorting code in the ls.rs
file so I wonder how it's getting sorted?
A git bisect would be helpful to figure out what PR broke this functionality.
Agreed - Just wanted to make sure I got the issue in since I didn't have enough time at that point to do the bisect.
Has anyone done a Nushell git bisect
script that auto-runs based on assert
's?
I think @amtoine has a git bisect
script. Maybe this? https://github.com/amtoine/nu-git-manager/blob/main/docs/nu-git-manager-sugar/git/gm-repo-bisect.md
Maybe this?
Excellent - That worked great.
Bisected to #12625 / https://github.com/nushell/nushell/commit/460a1c8f874b503cb4140619838be483600f00ce
cc: @WindSoilder
i'm glad my script was useful to someone else than me :pray:
Actually I don't think ls
shold guarantee the order of output. It's sorted by date occasionally, maybe users shouldn't rely on it.
Actually I don't think
ls
shold guarantee the order of output. It's sorted by date occasionally, maybe users shouldn't rely on it.
I disagree. Historically (other shells/binaries) and AFAIK universally (other than Nushell 0.95), it is deterministic:
External ls
on *nix:
> (^ls) == (^ls (pwd))
true
eza
on *nix:
> (^eza) == (^eza (pwd))
true
lsd
on *nix:
> (^lsd) == (^lsd (pwd))
true
On Windows, using CMD (using Nu for the assertion):
> (cmd.exe /C "dir /b") == (cmd.exe /C "dir /b %cd%")
true
On Windows, using PowerShell (using Nu for the assertion):
> (pwsh.exe -c "Get-ChildItem | Select-Object -ExpandProperty Name") == (pwsh.exe -c "Get-ChildItem (pwd) | Select-Object -ExpandProperty Name")
true
And for completeness:
Nushell 0.93:
> (ls -s | get name) == (ls -s (pwd) | get name)
true
Nushell 0.94.x/0.95:
> (ls -s | get name) == (ls -s (pwd) | get name)
false
It seems to me a completely normal expectation that the sort-order will remain the same regardless of whether ls
was called with or without a path specifier. I think this is a regression.
I think we should restore prior sort too, although I don't understand how that PR changed it. 🤔
Hey, made a Pr for this that I tested locally.
Seems that the use of read_dir
was brought in the mentioned Bisect and from the rust docs we can see that it does not provide consistency in ordering.
As far as I could see if we do not specify a directory/path we make no call to read_dir
in the changed file (one type of order) and when we add an argument/path after ls
we do call read_dir
(hence the second order type).
The advised solution for consistency was to sort it manually. Gonna finish that of by saying that my grasp on rust aint the best yet, so improvements are welcome if someone has to offer.
@userwiths The key to this change will be to ensure that it continues streaming and doesn't collect.
Describe the bug
This appears to have changed/broken in 0.94, but (once again), I left my long-running script running for too long under 0.93. When I skipped forward to 0.95, this broke my script, since it was trying to get the
ls <dir> | last
file from the directory. That filename was no longer the same as it had been in 0.93.How to reproduce
Expected behavior
Sort
ls
output by filename, even when a directory path is specified.Screenshots
No response
Configuration
Additional context
No response