summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauri Kasanen2018-08-01 19:51:17 +0300
committerDenys Vlasenko2018-08-01 19:47:15 +0200
commita380aacca61271e24656df237d73fb9930702ff1 (patch)
tree301da5dc238d7ce688c47af7375ff31e51da7d4e
parent9408978a438ac6c3becb2216d663216d27b59eab (diff)
downloadbusybox-a380aacca61271e24656df237d73fb9930702ff1.zip
busybox-a380aacca61271e24656df237d73fb9930702ff1.tar.gz
ls: When -h is passed, the total should also be in human units
Signed-off-by: Lauri Kasanen <cand@gmx.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/ls.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4be4990..b1c3068 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -1016,7 +1016,15 @@ static void scan_and_display_dirs_recur(struct dnode **dn, int first)
subdnp = scan_one_dir((*dn)->fullname, &nfiles);
#if ENABLE_DESKTOP
if (option_mask32 & (OPT_s|OPT_l)) {
- printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
+ if (option_mask32 & OPT_h) {
+ printf("total %-"HUMAN_READABLE_MAX_WIDTH_STR"s\n",
+ /* print size, no fractions, use suffixes */
+ make_human_readable_str(calculate_blocks(subdnp) * 1024,
+ 0, 0)
+ );
+ } else {
+ printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
+ }
}
#endif
if (nfiles > 0) {