Change 'ls -l -h' formatting to match GNU ls

Before:
-rw-r--r--  1 arni arni  2.02 kB 2018-09-14 21:07 CONTRIBUTING.md
-rw-r--r--  1 arni arni 78.75 kB 2018-09-14 23:41 Cargo.lock
-rw-r--r--  1 arni arni  6.92 kB 2018-09-14 21:07 Cargo.toml
-rw-r--r--  1 arni arni  1.05 kB 2018-09-14 21:07 LICENSE
-rw-r--r--  1 arni arni  5.98 kB 2018-09-14 21:07 Makefile
-rw-r--r--  1 arni arni 10.68 kB 2018-09-14 21:07 README.md
-rw-r--r--  1 arni arni  2.22 kB 2018-09-14 21:07 appveyor.yml
-rw-r--r--  1 arni arni   2.9 kB 2018-09-14 21:07 build.rs
-rw-r--r--  1 arni arni     15 B 2018-09-14 21:07 codecov.yml
drwxr-xr-x  2 arni arni   4.1 kB 2018-09-14 21:07 docs
-rw-r--r--  1 arni arni    973 B 2018-09-14 21:07 mkmain.rs
drwxr-xr-x 97 arni arni   4.1 kB 2018-09-14 21:07 src
drwxr-xr-x  3 arni arni   4.1 kB 2018-09-14 21:08 target
drwxr-xr-x  4 arni arni   4.1 kB 2018-09-14 21:07 tests
-rw-r--r--  1 arni arni     48 B 2018-09-14 21:07 uumain.rs

After:
-rw-r--r--  1 arni arni  2.02K 2018-09-14 21:07 CONTRIBUTING.md
-rw-r--r--  1 arni arni 78.68K 2018-09-16 20:39 Cargo.lock
-rw-r--r--  1 arni arni  6.92K 2018-09-14 21:07 Cargo.toml
-rw-r--r--  1 arni arni  1.05K 2018-09-14 21:07 LICENSE
-rw-r--r--  1 arni arni  5.98K 2018-09-14 21:07 Makefile
-rw-r--r--  1 arni arni 10.68K 2018-09-14 21:07 README.md
-rw-r--r--  1 arni arni  2.22K 2018-09-14 21:07 appveyor.yml
-rw-r--r--  1 arni arni   2.9K 2018-09-14 21:07 build.rs
-rw-r--r--  1 arni arni     15 2018-09-14 21:07 codecov.yml
drwxr-xr-x  2 arni arni   4.1K 2018-09-14 21:07 docs
-rw-r--r--  1 arni arni    973 2018-09-14 21:07 mkmain.rs
drwxr-xr-x 97 arni arni   4.1K 2018-09-14 21:07 src
drwxr-xr-x  3 arni arni   4.1K 2018-09-14 21:08 target
drwxr-xr-x  4 arni arni   4.1K 2018-09-14 21:07 tests
-rw-r--r--  1 arni arni     48 2018-09-14 21:07 uumain.rs
This commit is contained in:
Árni Dagur 2018-09-16 20:42:11 +00:00
parent 1f64d83d6f
commit 9207269791
No known key found for this signature in database
GPG key ID: 3FA0FE37648D1145

View file

@ -507,6 +507,9 @@ fn display_date(metadata: &Metadata, options: &getopts::Matches) -> String {
fn display_file_size(metadata: &Metadata, options: &getopts::Matches) -> String {
if options.opt_present("human-readable") {
convert(metadata.len() as f64)
.replace(" ", "")
.trim_right_matches("B")
.to_uppercase()
} else {
metadata.len().to_string()
}