Using less in environment without controlling tty
ralda at gmx.de
Mon Jul 29 13:54:03 UTC 2013
>> ... or are there any other suggestions on how to use less in
>> such a situation?
>Solution #1: get yourself a ctty. This will solve whole slew
>of problems, instaed of fixing them one at a time.
No! This assumption is wrong. Think of a multi headed display.
Controlling terminal is for example tty2 and now you start a
script which wants to show up some text file on ttyS1 (an
external display on serial line). You do not want to change the
controlling tty for this. And then there is no way to use
Busybox less to display your messages on ttyS1. Standard less
has no trouble with this, and I used it so many times for such
type of display.
>Solution #2: implement something like "less --tty TTY"
Another long option? I hate long options, and short options
produce collision with other standard less options :( ... why not
behave like standard less and use stdout? If it is not a tty,
less behaves like cat, else switch stdout to raw mode, use for
viewing messages/keyboard input, then switch back to saved
settings before exit. If there is a program running concurrently
on same tty, I consider it a missconfiguration. If any other
program (shell) waits for exit of less (as expected), then it
shall not see if less changed fd to nonblocking I/O or changed
any other setting during it's operation, as long as less restores
tty settings (including blocking status) before exit.
More information about the busybox