← Commit list

a380aacca

Lauri Kasanen
Lauri Kasanen
2018-08-01
SUCCESS Duration: 145s

Subject

ls: When -h is passed, the total should also be in human units

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/ls.c+9 -1
@@ -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) {