Using less in environment without controlling tty

Harald Becker ralda at gmx.de
Fri Jul 26 23:14:51 UTC 2013


Hi Laurent !

>> My current (temporary) fix for this is, to patch Busybox to use
>> fd #2 (stderr) als kbd_fd (kbd_fd = 2;) then it is possible to
>> redirect output of less to any location you like:
>> 
>>  ... | less 2<>/dev/ttyN
>
> The problem of this approach is that it bypasses the built-in
>tests in less, so if someone on your system uses less on a
>non-terminal fd, it will crash and burn ^^

I just looked into source of less ... it uses fd 1 (stdout) for
it's display and behaves like cat if fd 1 is not a tty. Why
can't we follow this principle in Busybox. Why do we need to
explicitly do an open on /dev/tty? My temporary fix was to use fd
2 for kbd_fd, but it looks like it should just be fd 1, and a
check if it's a tty (required? ... else termios shall fail).

--
Harald


More information about the busybox mailing list