less -S does not "truncate" lines

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

less -S does not "truncate" lines

George Brown
When viewing a file with "less -S" that has lines longer than $COLUMNS
said lines are simply not wrapped. The contents of said lines is still
available, one simply needs to scroll horizontally. I would have
expected the contents displayed within less to be as if I had run
something like "cut -c 1-$COLUMNS file".

I came across this as I was wondering why "less -FS" was still
paginating on inputs with long lines that would have otherwise fit on
the screen.

I have observed this behaviour on the following platforms.

    * OpenBSD 6.5
    * OpenBSD 6.5 - current (snapshot 2019-07-19)
    * FreeBSD 12
    * Ubunutu 19.04
    * macOS 10.14.5

Given the consistent behaviour I would think it is my expectation that
is wrong rather than the observed result.

It could be argued this is a "visual truncation" from the current view.
However in my mind the word "truncation" has a very specific meaning of
dropping a remainder such that it is no longer available at all. As such
I would suggest an alteration to the description in the man page.

For reference the GNU less man page is the only one that doesn't use the
word "truncate", instead describing it as "chopped rather than folded".

diff --git a/usr.bin/less/less.1 b/usr.bin/less/less.1
index 52d2049562e..22c3324ea0f 100644
--- a/usr.bin/less/less.1
+++ b/usr.bin/less/less.1
@@ -499,10 +499,7 @@ each type of control character).
 Thus, various display problems may result,
 such as long lines being split in the wrong place.
 .It Fl S | -chop-long-lines
-Causes lines longer than the screen width to be
-chopped (truncated) rather than wrapped.
-That is, the portion of a long line that does not fit in
-the screen width is not shown.
+Lines longer than the screen width will not be wrapped.
 The default is to wrap long lines; that is, display the remainder
 on the next line.
 .It Fl s | -squeeze-blank-lines

Reply | Threaded
Open this post in threaded view
|

Re: less -S does not "truncate" lines

Ingo Schwarze
Hi George,

George Brown wrote on Sat, Jul 20, 2019 at 01:29:37PM +0100:

> When viewing a file with "less -S" that has lines longer than $COLUMNS
> said lines are simply not wrapped. The contents of said lines is still
> available, one simply needs to scroll horizontally. I would have
> expected the contents displayed within less to be as if I had run
> something like "cut -c 1-$COLUMNS file".
>
> I came across this as I was wondering why "less -FS" was still
> paginating on inputs with long lines that would have otherwise fit on
> the screen.
>
> I have observed this behaviour on the following platforms.
>
>     * OpenBSD 6.5
>     * OpenBSD 6.5 - current (snapshot 2019-07-19)
>     * FreeBSD 12
>     * Ubunutu 19.04
>     * macOS 10.14.5
>
> Given the consistent behaviour I would think it is my expectation that
> is wrong rather than the observed result.
>
> It could be argued this is a "visual truncation" from the current view.
> However in my mind the word "truncation" has a very specific meaning of
> dropping a remainder such that it is no longer available at all. As such
> I would suggest an alteration to the description in the man page.
>
> For reference the GNU less man page is the only one that doesn't use the
> word "truncate", instead describing it as "chopped rather than folded".

Both of the words "truncate" and "chop" seem more likely to be
understood as permanant deletion rather than temporary hiding, so
both are best avoided.  I committed the following patch which is
shorter and simpler, and which also describes the option in a
positive rather than a negative way.

Yours,
  Ingo


CVSROOT: /cvs
Module name: src
Changes by: [hidden email] 2019/07/20 07:21:10

Modified files:
        usr.bin/less   : less.1

Log message:
Correct misleading description of -S;
problem reported by George Brown <321 dot george at gmail dot com> on tech@.

Index: less.1
===================================================================
RCS file: /cvs/src/usr.bin/less/less.1,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- less.1 26 May 2019 01:16:09 -0000 1.54
+++ less.1 20 Jul 2019 13:21:09 -0000 1.55
@@ -499,10 +499,8 @@
 Thus, various display problems may result,
 such as long lines being split in the wrong place.
 .It Fl S | -chop-long-lines
-Causes lines longer than the screen width to be
-chopped (truncated) rather than wrapped.
-That is, the portion of a long line that does not fit in
-the screen width is not shown.
+Display only the beginning of lines that exceed the screen width.
+The remainder can be shown by scrolling horizontally.
 The default is to wrap long lines; that is, display the remainder
 on the next line.
 .It Fl s | -squeeze-blank-lines

Reply | Threaded
Open this post in threaded view
|

Re: less -S does not "truncate" lines

George Brown
Hi Ingo,

Yes the usage of "truncate" and "chop" are unfortunate. I agree positive
language is always better.

Many thanks,
George