[illumos-Developer] Requesting code review for opensource /usr/xpg4/bin/more replacement with "less" ...

Joerg Schilling Joerg.Schilling at fokus.fraunhofer.de
Tue Jan 18 08:06:19 PST 2011


"Garrett D'Amore" <garrett at damore.org> wrote:

> > A quick check with calling /usr/bin/less as more (more /etc/passwd) shows a 
> > flicker and then it looks as if nothing happened.
> > 
> > It would be nice if things were so simple that you really can use less to 
> > replace /usr/xpg4/bin/more.
> > 
> > Jörg
> > 
>
> I think the problem you are seeing is a bug in xterm or TERMCAP, not in
> less.
>
> Specifically, less behaves as more -e by default (which might be argued
> to be a bug) when called as more.
>
> Given a short file (say /etc/motd), the output from less is not
> displayed on the terminal.  But truss shows that it did indeed write()
> to the tty.
>
> Notably, XPG4 more -e suffers from the same bug.

I am very sure this is a less bug.

less sends ^[[?1l^[>^[7^[[?47h^[[?1h^[= at startup and
^[[K^[[?1l^[>^[[2J^[[?47l^[8 at the end

startup:
^[[?1l^[>	leave 'keyboard_transmit' mode
^[7		save current cursor position
^[[?47h		use alternate screen buffer
^[[?1h^[= 	enter 'keyboard_transmit' mode

exit:
^[[K		clear to end of line
^[[?1l^[>	leave 'keyboard_transmit' mode
^[[2J		clear screen
^[[?47l		return from alternate screen buffer
^[8		restore cursor to last position of save_cursor

As you see, this is intentionally wrong. It would be OK as long as it would not 
exit after finishing to display the content (which is true in less mode).

Jörg

-- 
 EMail:joerg at schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
       js at cs.tu-berlin.de                (uni)  
       joerg.schilling at fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily



More information about the Developer mailing list