Does not support patterns containing escaped newline character, except with -P

Bug #1641092 reported by Jarno Suni
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
grep (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

$ printf 'a
b\0b' | grep --null-data "a
b" | hexdump -C
00000000 61 0a 62 00 62 00 |a.b.b.|
00000006

expect
00000000 61 0a 62

EDIT:

Apparently, in the above the pattern string is considered as two patterns 'a' and 'b'.

With -P you get

$ printf 'a\nb\0b' | grep -zP 'a
b' | hexdump -C
grep: the -P option only supports a single pattern

However, if the newline is coded as '\n' in the pattern, it works, but only with -P

$ printf 'a\nb\0b' | grep -zP 'a\nb' | hexdump -C
00000000 61 0a 62 00 |a.b.|
00000004
$ printf 'a\nb\0b' | grep -z 'a\nb' | hexdump -C
$ printf 'a\nb\0b' | grep -zE 'a\nb' | hexdump -C
$ printf 'a\nb\0b' | grep -zF 'a\nb' | hexdump -C

I expect it should work by other matcher selectors than -P, too.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: grep 2.25-1~16.04.1
ProcVersionSignature: Ubuntu 4.4.0-45.66-generic 4.4.21
Uname: Linux 4.4.0-45-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: XFCE
Date: Fri Nov 11 12:58:27 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2015-11-21 (355 days ago)
InstallationMedia: Xubuntu 15.10 "Wily Werewolf" - Release amd64 (20151021)
SourcePackage: grep
UpgradeStatus: Upgraded to xenial on 2016-06-24 (139 days ago)

Revision history for this message
Jarno Suni (jarnos) wrote :
Jarno Suni (jarnos)
description: updated
Revision history for this message
Jarno Suni (jarnos) wrote :

In awk \n in regex means newline.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grep (Ubuntu):
status: New → Confirmed
Jarno Suni (jarnos)
description: updated
summary: - Does not support patterns containing newline
+ Does not support patterns containing escaped newline character, except
+ with -P
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.