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

Garrett D'Amore garrett at damore.org
Tue Jan 18 08:12:05 PST 2011


On Tue, 2011-01-18 at 17:06 +0100, Joerg Schilling wrote:
> "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).

So there is a bug here.

Fixing this bug is probably a good idea, and probably less effort than
rewriting more from scratch.  Again, we don't have the source for xpg4
more.

That said, I've not assessed what it would take to make /usr/bin/more
suitable as a replacement for xpg4 more.

	- Garrett





More information about the Developer mailing list