GNU bug report logs -
#25513
Issue grepping lines ending with CRLF with --color=auto.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25513 in the body.
You can then email your comments to 25513 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#25513
; Package
grep
.
(Mon, 23 Jan 2017 16:37:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eric Hoffman <ehoffman <at> positronaccess.com>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Mon, 23 Jan 2017 16:37:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello!
grep is behaving differently when outputting with --color=auto when lines are ending with CRLF (like Windows text files).
The issue is that if I have a file with CRLF line terminator, for example, a file named test.txt, containing:
Line 1<CR><LF>
Line 2<CR><LF>
Line 3<CR><LF>
Or:
$od -c test.txt
0000000 L i n e 1 \r \n L i n e 2 \r \n
0000020 L i n e 3 \r \n
0000030
Then, If I type:
$ grep --color=auto "." test.txt
That is, I tell grep to display every lines containing at least one character (that is, every lines), I get on terminal output just 3 empty lines. However, if I type:
$ grep "." test.txt
Line 1
Line 2
Line 3
Then I do have every lines on the output.
I tried on both SSH and direct console with same result.
On my SSH terminal, I captured output, and what I see is
<CR><LF>
<CR><LF>
<CR><LF>
Here are a few variations:
- I tried with a longer file, like 100 lines, and I do get some of the lines printed, but truncated to the terminal screen width.
- The issue here was with printing every lines, but I do get the same result as long as I match any end of lines, like grep "2.*" test.txt, or even "grep 2[[:cntrl:]]$" test.txt
- The problem is there only when
This was with grep 2.27 (also tried 2.16, which I had before upgrading to 2.27).
Regards,
Eric
[Message part 2 (text/html, inline)]
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Mon, 23 Jan 2017 17:14:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Eric Hoffman <ehoffman <at> positronaccess.com>
:
bug acknowledged by developer.
(Mon, 23 Jan 2017 17:14:01 GMT)
Full text and
rfc822 format available.
Message #10 received at 25513-done <at> debbugs.gnu.org (full text, mbox):
tags 25513 notabug
thanks
On Mon, Jan 23, 2017 at 8:03 AM, Eric Hoffman
<ehoffman <at> positronaccess.com> wrote:
> grep is behaving differently when outputting with --color=auto when lines are ending with CRLF (like Windows text files).
>
> The issue is that if I have a file with CRLF line terminator, for example, a file named test.txt, containing:
> Line 1<CR><LF>
> Line 2<CR><LF>
> Line 3<CR><LF>
>
> Or:
>
> $od -c test.txt
> 0000000 L i n e 1 \r \n L i n e 2 \r \n
> 0000020 L i n e 3 \r \n
> 0000030
>
> Then, If I type:
> $ grep --color=auto "." test.txt
...
Thank you for the report. I too see that behavior, but it is not a
problem with grep. It is due to the way carriage returns are rendered.
Here, even without --color, you can see that the three matched line
render as empty:
$ printf 'line%s\r\n' 1 2 3 | grep .
However, if you pipe that result through cat -A, you see that grep is
working as required:
$ printf 'line%s\r\n' 1 2 3 | grep .|cat -A
line1^M$
line2^M$
line3^M$
So I'm closing this bug.
Information forwarded
to
bug-grep <at> gnu.org
:
bug#25513
; Package
grep
.
(Tue, 24 Jan 2017 12:30:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 25513 <at> debbugs.gnu.org (full text, mbox):
That was something I suspected. On my system, I taught it was doing the same with 'grep' alone too, but it turned out my default .bashrc setup an alias for 'bash' to ass '--color=auto'. I do get the same issue if I type...
$ printf 'line%s\r\n' 1 2 3 | grep .
...because of the alias, buy typing...
$printf 'line%s\r\n' 1 2 3 | /bin/grep .
...does not cause issue.
Indeed, it does not cause an issue in a script, as the text is sent through the pipe without color rendering.
So, I was wondering if it was grep or not.
Regards,
Eric
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 22 Feb 2017 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 112 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.