buggrep - Bugs: bug #36831, single character swallowed in...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

bug #36831: single character swallowed in output

Submitted by:  None
Submitted on:  Thu 12 Jul 2012 07:34:58 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Thu 02 Jan 2014 07:28:29 PM UTC, comment #3:

the source code has a very long explanation on the topic:
http://git.savannah.gnu.org/cgit/grep.git/tree/src/main.c?id=88d65410f7aa472c66da1bdf01c3cc1439cefce6#n142

with the simple workaround:
export GREP_COLORS=ne

simpler test case is:
printf '%*s\n' $COLUMNS X | grep --color=always X

i also think this is a dup of bug 25539

Mike Frysinger <vapier>
Sat 20 Jul 2013 12:03:43 AM UTC, comment #2:

Looking into this, it's definitely the same problem. When grep is in color mode it outputs the control sequence

unmatched text ^[[01;31m^[[Kmatched text^[[m^[[K^M

If the matched text goes to the end of line, by the vt100 spec the cursor remains at the end of line on the last character. This means the subsequent ^[[K (erase from cursor to end of line) erases the last character of the matched text. This depends on the terminal, gnome-terminal and konsole treat the erase to end of line differently after writing the last character on the current line.

Does anyone know why the erase to end of line is necessary, given when in no color mode grep just prints "unmatched text matched text^M" with no erase codes? Removing these should fix the problem on all terminals.

Robert Flack <flackr>
Fri 19 Jul 2013 10:07:47 PM UTC, comment #1:

I've been seeing a similar issue which is perhaps the same. If you run the following command but substitute your terminal width in characters for XXX the colored "1" is missing from the output in most terminals (except for gnome-terminal).

printf "%0XXXd test\n" 1|grep 1

Robert Flack <flackr>
Thu 12 Jul 2012 07:34:58 AM UTC, original submission:

In one of multiple lines of output grep swallowed one character from an instance of the searched word (see last but two line in attached screenshot).

This doesn't happen when --color=never is given on the command line.

Anonymous

 

Attached Files
file #26183:  grep-bug-or-feature.png added by None (23kB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by vapier (Posted a comment)
  • -unavailable- added by vapier
  • -unavailable- added by flackr (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 02 Jan 2014 07:28:29 PM UTCvapierCarbon-Copy-=>Added -unavailable-
    Thu 12 Jul 2012 07:34:58 AM UTCNoneAttached File-=>Added grep-bug-or-feature.png, #26183

    Back to the top


    Powered by Savane 3.1-cleanup