Package: byobu
Version: 5.133-1
Severity: normal
File: /usr/lib/byobu/disk_io
Tags: patch

Dear Maintainer,

Since upgrading to bullseye, the disk_io status notification fails to show
instantaneous statistics, and shows instead a persistent cumulative total of
all I/O.

The problem is due to the interaction between lines 65 and 75:

65>                     [ -r "$cache" ] && read x1 < "$cache" || x1=0

75>                     printf "%s" "$x2" > "$cache"

Because the $cache file is written without a terminating newline, the read
builtin returns failure, causing the || operator to execute x1=0.

According to sh(1):
>                             The read builtin will indicate success unless
>           EOF is encountered on input, in which case failure is returned.

A further problem is that when the I/O rate is below the $DISK_IO_THRESHOLD,
the previous statistics remain visible and are not cleared from the status
line.

The attached patch corrects these problems.


-- System Information:
Debian Release: 11.0
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-8-amd64 (SMP w/2 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages byobu depends on:
ii  debconf [debconf-2.0]  1.5.77
ii  gawk                   1:5.1.0-1
ii  gettext-base           0.21-4
ii  iproute2               5.10.0-4
ii  python3                3.9.2-3
ii  python3-newt           0.52.21-4+b3
ii  tmux                   3.1c-1

Versions of packages byobu recommends:
ii  less            551-2
pn  pastebinit      <none>
pn  run-one         <none>
ii  sensible-utils  0.0.14

Versions of packages byobu suggests:
pn  apport                  <none>
pn  ccze                    <none>
ii  gnupg                   2.2.27-2
ii  lsb-release             11.1.0
ii  po-debconf              1.0.21+nmu1
pn  screen                  <none>
pn  speedometer             <none>
pn  ttf-ubuntu-font-family  <none>
pn  update-notifier-common  <none>
ii  vim                     2:8.2.2434-3
pn  wireless-tools          <none>
ii  xterm                   366-1

-- debconf information excluded
--- /usr/lib/byobu/disk_io      2020-02-17 06:11:50.000000000 -0800
+++ .byobu/bin/disk_io  2021-08-25 14:24:57.322324975 -0700
@@ -72,11 +72,12 @@
                                symbol="$ICON_WR"
                                [ -n "$a7" ] && x2="$a7" || x2=0
                        fi
-                       printf "%s" "$x2" > "$cache"
+                       printf "%s\n" "$x2" > "$cache"
                        rate=$((($x2 - $x1) / ($t2 - $t1) * 512 / 1024))
                        if [ $rate -lt $DISK_IO_THRESHOLD ]; then
                                # Below threshold, don't print
-                               continue
+                               #continue
+                               rate=""
                        elif [ "$rate" -lt 0 ]; then
                                rate=0
                        elif [ "$rate" -gt 1048576 ]; then

Reply via email to