In bash 5.3 the fractional part for the cpu reported
by the time keyword always shows zeros:

$ TIMEFORMAT="cpu: %P"
$ time
cpu: 96.00

The fix:

Patch (apply with `patch -p0'):

--- execute_cmd.c  Thu Jun  5 10:02:01 2025
+++ ../bash-5.3-patched/builtins/execute_cmd.c  Mon Sep 29 04:16:26 2025
@@ -1380,7 +1380,7 @@
       cpu = 10000;
#endif
     sum = cpu / 100;
-    sum_frac = (cpu % 100) * 10;
+    sum_frac = (cpu % 100) * 10000;  // mkfmt() expects the fractional part to 
be in microseconds.
     len = mkfmt (ts, 2, 0, sum, sum_frac);
     RESIZE_MALLOCED_BUFFER (str, sindex, len, ssize, 64);
     strcpy (str + sindex, ts);
--



  • [PATCH] cpu Pourko via Bug reports for the GNU Bourne Again SHell

Reply via email to