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

 
 

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

bug #36831: single character swallowed in output

Submitter:  None
Submitted:  Thu 12 Jul 2012 07:34:58 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Wed 27 Mar 2024 08:28:23 AM UTC, comment #4: 

This bug has a duplicate, with a more elaborate discussion, at
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15444

Egmont Koblinger <egmont>
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

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-02 vapier Carbon-Copy- Added -email is unavailable-
    2012-07-12 None Attached File- Added grep-bug-or-feature.png, #26183

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code