Ah, after using UNIX and variants for over a decade I finally discovered the source of this utterly baffling problem. And now I will share my hard-gained wisdom with you, gentle readers:
The problem is SIGWINCH. Let's say you call up an xterm in your favorite 80x25 or 80x40 or 120x40 etc. Then you invoke your favorite pager on some really wide file. The lines are wrapped, so you make the xterm wider. This works fine. Afterwards, you go back to the shell, but your long command lines are all screwed up! Egads!
What's happened is SIGWINCH, the signal sent to programs when the size of the controlling terminal changes, we delivered to your pager (less, more, whatever). It was NOT delivered to your shell. So the shell, which is probably using readline for command editing, has no idea the terminal is now 281 characters across. This causes major problems inside the readline library, and is why editing long command lines often barfs.
The workaround: just resize the terminal a bit when you see the problem. This will deliver the SIGWINCH to the program you are currently using, and make everything look correct again.
A real solution would be for the shell (or readline, or some other bit of code) to check the size of the controlling terminal whenever it resumes control of it, when children exit, or whenever it might have changed unnoticed.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds