less icon indicating copy to clipboard operation
less copied to clipboard

Search with buffer (-B) over pipe not working as expected

Open Roslaniec opened this issue 1 year ago • 1 comments

I see some glitches when using buffer (-B) with search and piped stream

First test scenario: perl -e 'for (my $i=0; ; $i++) { print($i.("x"x100)."\n"); print "$i test\n" if ($i<400 and !($i%100)); }' | less -nBb1

  • Press: /test
  • Press: n
  • Press: UP or DOWN arrow: nothing happens; less is stuck.
  • Press: LEFT or RIGHT arrow and you will see status: Cannot seek to that file position
  • Press: n again and status is: Pattern not found. Notice that program is still running in background, but less is stuck without progress

Roslaniec avatar Aug 24 '23 20:08 Roslaniec

Second scenario is even more interesting. Unzip attached file test.gz

( cat /tmp/test; sleep 10000 ) | less -SBnb100

  • Enter: /asbcuBfDxkOwf379kKqCyg6UidFq
  • Press: nn
  • You will see: Cannot seek to that file position (press RETURN)
  • Press: Ctrl-C
  • Press: UP arrow

At this point program will be stopped and moved into background. To kill it, you need to do fg, Ctrl-C, q[ENTER]

If you press "q" after Ctrl-C (instead of UP arrow), the program will be stopped and goes into the background as well. But after fg it will immediately quit. This means that the 'q' input was somehow buffered.

Roslaniec avatar Aug 24 '23 21:08 Roslaniec