[git commit] ls: When -h is passed, the total should also be in human units
Denys Vlasenko
vda.linux at googlemail.com
Wed Aug 1 17:47:15 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=a380aacca61271e24656df237d73fb9930702ff1
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Lauri Kasanen <cand at gmx.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
coreutils/ls.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4be499088..b1c306809 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) {
More information about the busybox-cvs
mailing list