[PATCH v2] less: improvements to verbose status messages

Ron Yorston rmy at pobox.com
Wed Jul 22 08:35:57 UTC 2015


Ron Yorston wrote:
>Better, though, might be to put the test in open_file_and_read_lines,
>where all input files are opened.  This would prevent read_lines from
>trying to read non-regular files.

Actually, my concern that read_lines might react badly to being fed
/dev/zero was misplaced.  read_lines doesn't deal in lines as we know
them, it handles terminal-width-sized partial lines, and it inserts a
fake EOF after it's read MAXLINES of these things.

So even if its input has no newlines and no EOF read_lines will eventually
terminate.

I still think it would be better to detect non-regular files earlier
and I'll put together a patch for that.

>The real 'less' does this:
>
>   [rmy at vulcan ~]$ less /dev/zero
>   /dev/zero is not a regular file (use -f to see it)
>   [rmy at vulcan ~]$

Interestingly if you try -f it doesn't work as well as BusyBox less.
'less -f /dev/zero' is OK but 'less -f -S /dev/zero' loops forever
(or until it fills memory, I killed it after 2GB).

Ron


More information about the busybox mailing list