[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71252: why does grep match literal newlines when there are none, eve
From: |
Philippe Cerfon |
Subject: |
bug#71252: why does grep match literal newlines when there are none, even with -z? |
Date: |
Tue, 28 May 2024 22:54:18 +0200 |
Hey.
I always thought, that grep is line based in a way that the current
string doesn't hold the line terminator.
If so, why does, e.g.:
$ printf 'foo' | grep $'\n'
foo
match?
Even with -z.
While:
$ printf 'foo\nbar' | grep -z $'\n'
foo
bar
would make sense to me, why does it also match:
$ printf 'foobar' | grep -z $'\n'
foobar
?
In PCRE mode:
$ printf 'foobar' | grep -P -z '\n'
$
No match, that I would expect.
$ printf 'foo\nbar' | grep -P -z '\n'
foo
bar
Match, again, expected.
But:
$ printf 'foobar' | grep -P -z $'\n'
foobar
Why does that match?
Thanks,
Philippe
- bug#71252: why does grep match literal newlines when there are none, even with -z?,
Philippe Cerfon <=