On 3/22/24 12:25, Dennis Clarke via Bug reports for GNU grep wrote:
Old Solaris 8, once fully patched, was definately
compliant with SUSv2 which is all of POSIX.1b-1993, POSIX.1c-1996
POSIX does not specify the behavior of grep when the input is not a text
file, and a file that ends in a non-n
$ (echo -n foo;sleep 10;echo bar)|time sh -c '(grep -q foo;echo $?)'00.00user
0.00system 0:10.00elapsed 0%CPU (0avgtext+0avgdata
2432maxresident)k0inputs+0outputs (0major+202minor)pagefaults 0swaps$ (echo -n
foo;sleep 10)|time sh -c '(grep -q foo;echo $?)'00.00user 0.00system
0:10.00elapsed 0%
$ (echo foo;sleep 10;echo bar)|time grep -q foo;echo $?0.00user 0.00system
0:00.00elapsed 50%CPU (0avgtext+0avgdata 2432maxresident)k0inputs+0outputs
(0major+107minor)pagefaults 0swaps0$
The shell hangs for 10 seconds on its child pids but grep does not!
On Thursday, March 21, 2024 at 11
Maybe the opposite: -only_lines_with_newline ? Most users consider a line at
EOF lacking a trailing newline as still a line, but perhaps some do not?
On Friday, March 22, 2024 at 04:25:38 AM EDT, Niels Möller
wrote:
Paul Eggert writes:
> On 3/21/24 06:57, Niels Möller wrote:
>> I'm h
On 3/21/24 22:58, jack...@fastmail.com wrote:
> Paul Eggert wrote:
>> although doable it would be a bit of a pain to program
>
> yup - sure would be a pain.
>
> If you're not sure whether your actual input of interest will end
> in a newline, can you add one, to "feed grep's newline hunger",
> thu
Neils noted:
>> (BTW, man page says about the -q option "Exit immediately with zero
>> status if any match is found", ...
If I had the master copy of that man page in front of me right now,
I'd change that to say "... if any matching line is found ..."
>> For the time being, I hacked together a
Paul Eggert writes:
> On 3/21/24 06:57, Niels Möller wrote:
>> I'm having grep -q read input from a pipe. I would like grep to exit
>> successfully as soon as a match occurs, without requiring the line to be
>> terminated by newline or EOF (unless the grep pattern includes '$', that
>> is).
>
> G