Subject: Possible visualization bug in GNU grep 3.1 (Ubuntu 18.04 x86_64)
From: Andrea Ranieri <[email-masked]>
To: [email-masked]
Date: Fri, 31 Jan 2020 11:38:15 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Dear grep maintainers,

I think I've found a file that makes grep display wrong things, namely
endlines when grep is run "alone", piping just two greps together vs. text
when the output is piped e.g. to more or hd (hexdump).

You can find this file attached, but the file is public and can be found in
this zipfile:
https://www-intuidoc.irisa.fr/files/2017/07/ComplementaryInfo_LMDHG.zip
(part of the Leap Motion Dynamic Hand Gesture (LMDHG) database:
https://www-intuidoc.irisa.fr/en/english-leap-motion-dynamic-hand-gesture-lmdhg-database/
).

The offending command is this one:

#> grep -v "Position\|hand type\|^\t\t$" ArticulationsOrder.txt | grep
'[^A-Z]' # outputs just endlines

While:

#> grep -v "Position\|hand type\|^\t\t$" ArticulationsOrder.txt | grep
'[^A-Z]' | more # outputs this lines
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"

METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"
METACARPAL   ="(63.1641, 111.558, 103.153)"
PROXIMAL     ="(63.1641, 111.558, 103.153)"
        INTERMEDIATE ="(32.0933, 130.062, 69.1525)"
DISTAL"      ="(21.6896, 137.526, 37.7594)"

I can reproduce this also on my Raspberry Pi 4 (with Ubuntu 18.04 and grep
v3.1 as well) and another x86_64 node with Xeon Silver belonging to a
research cluster (grep v2.20).

If you have any questions, do not hesitate to contact me. Thanks for all
the work you do.

Best regards
Andrea Ranieri

#> grep --version
grep (GNU grep) 3.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <
http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

#> uname -a
Linux zapp-brannigan 5.3.0-24-generic #26~18.04.2-Ubuntu SMP Tue Nov 26
12:34:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

#> alias | grep grep
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'

-- 
Andrea Ranieri, Ph.D.

Researcher
*National Research Council of Italy*
Via De Marini 6, 16149 Genova, Italy
Email: [email-masked]