From b465c34eeffc99ba6d5b390ed92209c08baa11e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reto=20Habl=C3=BCtzel?= Date: Sun, 11 Apr 2021 16:16:38 +0200 Subject: [PATCH] fix ls --- src/uu/ls/src/ls.rs | 2 +- src/uu/ls/src/version_cmp.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 4024328b5..d198f1588 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1042,7 +1042,7 @@ fn sort_entries(entries: &mut Vec, config: &Config) { .sort_by_key(|k| Reverse(get_metadata(k, config).map(|md| md.len()).unwrap_or(0))), // The default sort in GNU ls is case insensitive Sort::Name => entries.sort_by_key(|k| k.to_string_lossy().to_lowercase()), - Sort::Version => entries.sort_by(version_cmp::version_cmp), + Sort::Version => entries.sort_by(|a, b| version_cmp::version_cmp(a, b)), Sort::None => {} } diff --git a/src/uu/ls/src/version_cmp.rs b/src/uu/ls/src/version_cmp.rs index 3cd5989f1..4cd39f916 100644 --- a/src/uu/ls/src/version_cmp.rs +++ b/src/uu/ls/src/version_cmp.rs @@ -1,8 +1,9 @@ -use std::{cmp::Ordering, path::PathBuf}; +use std::cmp::Ordering; +use std::path::Path; -/// Compare pathbufs in a way that matches the GNU version sort, meaning that +/// Compare paths in a way that matches the GNU version sort, meaning that /// numbers get sorted in a natural way. -pub(crate) fn version_cmp(a: &PathBuf, b: &PathBuf) -> Ordering { +pub(crate) fn version_cmp(a: &Path, b: &Path) -> Ordering { let a_string = a.to_string_lossy(); let b_string = b.to_string_lossy(); let mut a = a_string.chars().peekable();