bug#55748: df: wrong column is checked in condition in total-verify.sh

2022-06-01 Thread Pádraig Brady

tag 55748 notabug
close 55748
stop

On 01/06/2022 09:01, Daniel Hofstetter wrote:

Hi,

While looking at
https://github.com/coreutils/coreutils/blob/master/tests/df/total-verify.sh
I noticed the following lines and I think "$5" in the last line (line
38 in the source code) should be "$6" because there are six columns in
the df output and '-' is in the sixth column of the row starting with
"total".

# Recognize df output lines like these:
# /dev/sdc1 0 0 0 - /c
# tmpfs 1536000 12965 1523035 1% /tmp
# total 5285932 787409 4498523 15% -
/^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:-|[0-9]+%) (.*)$/
or die "$0: invalid input line\n: $_";
if ($1 eq 'total' && $5 eq '-')


Notice the non capturing group, i.e. (?:)
This is because the percentage column is not needed
in the subsequent processing.
I.e. the following would work, but isn't needed.

cheers,
Pádraig

diff --git a/tests/df/total-verify.sh b/tests/df/total-verify.sh
index 87589d23d..d3f109d97 100755
--- a/tests/df/total-verify.sh
+++ b/tests/df/total-verify.sh
@@ -33,9 +33,9 @@ while (<>)
 # /dev/sdc1  0   0   0-  /c
 # tmpfs1536000   12965 15230351% /tmp
 # total5285932  787409 4498523   15% -
-/^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:-|[0-9]+%) (.*)$/
+/^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(-|[0-9]+%) (.*)$/
   or die "$0: invalid input line\n: $_";
-if ($1 eq 'total' && $5 eq '-')
+if ($1 eq 'total' && $6 eq '-')
   {
 $total == $2 or die "$total != $2";
 $used  == $3 or die "$used  != $3";






bug#55748: df: wrong column is checked in condition in total-verify.sh

2022-06-01 Thread Daniel Hofstetter
Hi,

While looking at
https://github.com/coreutils/coreutils/blob/master/tests/df/total-verify.sh
I noticed the following lines and I think "$5" in the last line (line
38 in the source code) should be "$6" because there are six columns in
the df output and '-' is in the sixth column of the row starting with
"total".

# Recognize df output lines like these:
# /dev/sdc1 0 0 0 - /c
# tmpfs 1536000 12965 1523035 1% /tmp
# total 5285932 787409 4498523 15% -
/^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:-|[0-9]+%) (.*)$/
or die "$0: invalid input line\n: $_";
if ($1 eq 'total' && $5 eq '-')

Regards,
Daniel