I did this to see if grep was at fault. Apparently it is the terminal! Any clues on how I got an xterm to mess up? (My crontab continues to morph. My trussxx is a strace with options and vi wrapper, evolved since i left Solaris and its 'truss'.):
$ crontab -l|(sleep 2 ; grep clam)& trussxx -p $!
[1] 23978
strace: Process 23978 attached
strace: Process 23985 attached
30 23 * * * /usr/bin/freshclam --datadir=/home/dgp/.clamtk/db --log=/home/dgp/.clamtk/db/freshclam.$(/bin/date +\%b-\%d-\%Y).log >/home/dgp/.clamtk/db/freshcla_cron.log 2>&1 ; /usr/local/bin/clamdscan --reload --log="$HOME/.clamtk/history/$(/bin/date +\%b-\%d-\%Y).log" >>.clamtk/history/clamscan.log 2>&1 ; if [ `fuser .clamtk/history/clamscan.log 2>/dev/null` = "" ]; then echo Still running >>.clamtk/history/clamscan.log ; else /usr/local/bin/clamdscan --quiet --multiscan --fdpass --log="$HOME/.clamtk/history/$(/bin/date +\%b-\%d-\%Y).log" / >>.clamtk/history/clamscan.log 2>&1 ; fi # freshclam update and clam-scan
===================================
23985 write(1, "30 23 * * * /usr/bin/fresh\33[01;31m\33[Kclam\33[m\33[K --datadir=/home/dgp/.\33[01;31m\33[Kclam\33[m\33[Ktk/db --log=/home/dgp/.\33[01;31m\33[Kclam\33[m\33[Ktk/db/fresh\33[01;31m\33[Kclam\33[m\33[K.$(/bin/date +\\%b-\\%d-\\%Y).log >/home/dgp/.\33[01;31m\33[Kclam\33[m\33[Ktk/db/fresh\33[01;31m\33[Kclam\33[m\33[K_cron.log 2>&1 ; /usr/local/bin/\33[01;31m\33[Kclam\33[m\33[Kdscan --reload --log=\"$HOME/.\33[01;31m\33[Kclam\33[m\33[Ktk/history/$(/bin/date +\\%b-\\%d-\\%Y).log\" >>.\33[01;31m\33[Kclam\33[m\33[Ktk/history/\33[01;31m\33[Kclam\33[m\33[Kscan.log 2>&1 ; if [ `fuser .\33[01;31m\33[Kclam\33[m\33[Ktk/history/\33[01;31m\33[Kclam\33[m\33[Kscan.log 2>/dev/null` = \"\" ]; then echo Still running >>.\33[01;31m\33[Kclam\33[m\33[Ktk/history/\33[01;31m\33[Kclam\33[m\33[Kscan.log ; else /usr/local/bin/\33[01;31m\33[Kclam\33[m\33[Kdscan --quiet --multiscan --fdpass --log=\"$HOME/.\33[01;31m\33[Kclam\33[m\33[Ktk/history/$(/bin/date +\\%b-\\%d-\\%Y).log\" / >>.\33[01;31m\33[Kclam\33[m\33[Ktk/history/\33[01;31m\33[Kclam\33[m\33[Kscan.log 2>&1 ; fi # fresh\33[01;31m\33[Kclam\33[m\33[K update and \33[01;31m\33[Kclam\33[m\33[K-scan\n", 965) = 965
========================
dgp@dgp-p6803w:~
$ stty -a
speed 38400 baud; rows 25; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
dgp@dgp-p6803w:~
$ echo $TERM
xterm
dgp@dgp-p6803w:~
$ pse xterm
UID PID PPID C STIME TTY TIME CMD
dgp 3841 1862 0 12:38 ? 00:00:03 xterm -T x3831 -n x3831 -geometry 80x25 -fn 12x24 -sb -vb -cn -sl 9999 -ls
dgp 3877 1862 0 12:38 ? 00:00:01 xterm -T x3867 -n x3867 -geometry 80x25 -fn 12x24 -sb -vb -cn -sl 9999 -ls
dgp 3913 1862 0 12:38 ? 00:00:01 xterm -T x3903 -n x3903 -geometry 80x25 -fn 12x24 -sb -vb -cn -sl 9999 -ls
dgp 3949 1862 0 12:38 ? 00:00:01 xterm -T x3939 -n x3939 -geometry 80x25 -fn 12x24 -sb -vb -cn -sl 9999 -ls
dgp@dgp-p6803w:~
$
-----Original Message-----
From: Paul Eggert <eggert@cs.ucla.edu>
To: David G. Pickett <dgpickett@aol.com>
Cc: 56843@debbugs.gnu.org
Sent: Sat, Jul 30, 2022 2:17 pm
Subject: Re: bug#56843: grep mangling lines
I'm not seeing the problem on Ubuntu 22.04 LTS, using grep 3.7 and GNOME
Terminal 3.44.0 using VTE 0.68.0 +BIDI +GNUTLS +ICU +SYSTEMD. The output
isn't even colored unless I pass something like '--color=always' to
'grep', which leads me to wonder whether you're using an alias for
'grep' instead of the real thing.
Here's how I tried to reproduce the problem. What happens when you try
the same thing on your platform? and what is your platform?
$ cat >x <<'EOF'
> 30 23 * * * /usr/bin/freshclam --datadir=/home/dgp/.clamtk/db
--log=/home/dgp/.clamtk/db/freshclam.$(/bin/date +\%b-\%d-\%Y).log
>/home/dgp/.clamtk/db/freshclam_cron.log 2>&1 ;
/usr/local/bin/clamdscan --config-file=/etc/clamav/clamd.conf --reload
--log="$HOME/.clamtk/history/$(/bin/date +\%b-\%d-\%Y).log"
>>.clamtk/history/clamscan.log 2>&1 ; /usr/local/bin/clamdscan
--config-file=/etc/clamav/clamd.conf --quiet --multiscan --fdpass
--log="$HOME/.clamtk/history/$(/bin/date +\%b-\%d-\%Y).log" $HOME
>>.clamtk/history/clamscan.log 2>&1 # freshclam update and clam-scan
> EOF
$ cat x | grep clam | diff x -
$ e=$(printf '\033')
$ cat x | grep --color=always clam | sed "s/$e\\[[0-9;]*.//g" | diff x -
$ which grep
/usr/bin/grep