Search code examples
bashgnugnu-coreutils

linux gnu less: long lines in buffer broken down when copy+pasting


In one of my Linux machines, I create a long line and pipe it to gnu less like this:

seq -w 1 999 | xargs echo | less

If I select the text that appears from gnu less (version 394), and copy+paste it somewhere else, the long line is broken down into multiple lines, each as long as the width of the terminal, which is not what I expected.

If I do the same in a different Linux box (less version 444), I can select from the gnu less buffer and copy+paste it somewhere else as one single long line, which is the desired behaviour. See image:

enter image description here

Effect of pasting into emacs, underired effect first, desired effect below:

enter image description here

In both linux boxes, if I use cat instead of less and select from the output in the terminal, I can also copy+paste everything in one single line:

seq -w 1 999 | xargs echo > /tmp/f
cat /tmp/f

In contrast, in both linux boxes, the more command behaves the other way around, also breaking down the long line into multiple lines when selecting for copy+pasting:

seq -w 1 999 | xargs echo > /tmp/f
more /tmp/f

Any ideas what might be going on? How can I copy+paste from a gnu less buffer with the same consistent behaviour I see when I do cat?


Solution

  • I compiled a newer version of less, and now it behaves as expected.