grep does not output null when -o -z is used
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grep (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
New
|
Undecided
|
Unassigned |
Bug Description
Impact
Grepping null terminated records with -o option does not work. There may be a newline in a matched string, so the output may be ambiguous as the matched parts are separated by newline. This bug prevents users from using grep in some scripts that they want to work in all supported releases.
Test Case
$ printf 'a\0b\0b1' | grep --null-data b | hexdump -C
00000000 62 00 62 31 00 |b.b1.|
00000005
but
$ printf 'a\0b\0b1' | grep -o --null-data b | hexdump -C
00000000 62 0a 62 0a |b.b.|
00000004
Expected result:
00000000 62 00 62 00 |b.b.|
00000004
Regression Potential
Not remarkable. Scripts using -o -z are broken anyway with the broken grep.
This is fixed in Xenial, but IMO should be fixed in Trusty, too.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: grep 2.16-1
ProcVersionSign
Uname: Linux 4.4.0-37-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.21
Architecture: amd64
CurrentDesktop: XFCE
Date: Wed Sep 7 22:48:42 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-09-21 (717 days ago)
InstallationMedia: Ubuntu-Studio 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.1)
SourcePackage: grep
UpgradeStatus: No upgrade log present (probably fresh install)
description: | updated |
Changed in grep (Ubuntu): | |
status: | New → Fix Released |
description: | updated |
description: | updated |
description: | updated |
summary: |
- grep does not output null when -o is used + grep does not output null when -o -z is used |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
<jarnos> I suggest Bug #1621226 should be SRUed.
<rbasak> jarnos: that's reasonable, but it's also a change in behaviour that users may be relying on, as grep tends to be used quite a bit in scripts.
<rbasak> So I'm not sure.
<rbasak> I added a task in the bug for you. Can discuss in there.