Sort ls case-insensitively by default (#1192)

This commit is contained in:
Jonathan Turner 2020-01-11 20:59:55 +13:00 committed by GitHub
parent 60043df917
commit 147bfefd7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,6 +122,17 @@ impl Shell for FilesystemShell {
}
Ok(o) => o,
};
let mut entries = entries.collect::<Vec<Result<std::fs::DirEntry, _>>>();
entries.sort_by(|x, y| match (x, y) {
(Ok(entry1), Ok(entry2)) => entry1
.path()
.to_string_lossy()
.to_lowercase()
.cmp(&entry2.path().to_string_lossy().to_lowercase()),
(Err(_), Ok(_)) => std::cmp::Ordering::Greater,
(Ok(_), Err(_)) => std::cmp::Ordering::Greater,
_ => std::cmp::Ordering::Equal,
});
let stream = async_stream! {
for entry in entries {
if ctrl_c.load(Ordering::SeqCst) {