Discussion:
Strange behavior about pattern matching on manual pages [FIXED]
(too old to reply)
Jamie Landeg-Jones
2017-12-06 22:04:11 UTC
Permalink
Hi,
I encounter a problem when viewing manuals via man(1) command.
The case is simple, when I try to search something, I press ‘/’, and then input the pattern, If it got something in the page, it will direct me into the specified place, and then, I continue with ’n’, and it goes well.
But the problem is, after a sequence of ’n’, the screen go to the end of the manual pages, and keeping press ’n’, I got annoying “...skipping...”, the page is full of skipping and parts of the end of the manual page.
Yes. This has been annoying me too - your email prompted me to finally work
on a fix for it!

Firstly, it isn't man(1) itself - man(1) uses more(1) as the pager.
more(1) is in itself actually the program less(1), running in "more
emulation mode".

And less(1) isn't FreeBSD native code - it's imported into the project
from http://www.greenwoodsoftware.com/less/

I noticed the very latest version of less(1) has been checked into
freebsd-current, and the issue still occurs there.

Anyway, the fix is two small patches to less(1), please let me know
if they work for you, and if you see any bad side-effects in man(1) /
more(1) and less(1) and I'll then try and get them applied upstream.

The patches have been tested against FreeBSD 11.1-STABLE and 12-CURRENT

cheers! Jamie

--- contrib/less/forwback.c.orig 2017-11-20 08:52:33.978356000 +0000
+++ contrib/less/forwback.c 2017-12-05 15:53:50.517550000 +0000
@@ -255,7 +255,7 @@
* start the display after the beginning of the file,
* and it is not appropriate to squish in that case.
*/
- if ((first_time || less_is_more) &&
+ if ((first_time) &&
pos == NULL_POSITION && !top_scroll &&
#if TAGS
tagoption == NULL &&
--- contrib/less/main.c.orig 2017-11-20 08:52:33.978356000 +0000
+++ contrib/less/main.c 2017-12-05 15:53:57.291394000 +0000
@@ -168,7 +168,10 @@
}

if (less_is_more)
+ {
no_init = TRUE;
+ scan_option("--tilde");
+ }

#if EDITOR
editor = lgetenv("VISUAL");
Alan Somers
2017-12-06 22:53:44 UTC
Permalink
How about just setting MANPAGER=less in your environment?
Because some of us prefer "more"?
And as I said, it's related to searching using the more(1) command
generally.
I was under the impression that fixing bugs in existing commands was a
better
solution than telling someone to simply use something else.
Yes, it certainly is. Are you sure this is actually a bug in less, or is
it just weird-but-intended behavior when less is emulating some old version
of more? It would be worth comparing our less sources to upstream's to see
what differences have crept in, and svn blaming them to see why.

-Alan
Jamie Landeg-Jones
2017-12-14 16:39:26 UTC
Permalink
Post by Alan Somers
Yes, it certainly is. Are you sure this is actually a bug in less, or is
it just weird-but-intended behavior when less is emulating some old version
of more? It would be worth comparing our less sources to upstream's to see
what differences have crept in, and svn blaming them to see why.
Firstly, apologies for the delay in replying - I've been away.

I was planning on investigating further, which is why I hadn't yet formally
submitted it. Your info would have been a useful next step to follow, so cheers.
I finally traced down the origin of this weird behavior. It dates from
FreeBSD r60816, which imported NetBSD's r1.6 (from CVS), which fixed NetBSD
regresses the problem described by PR 227. So I don't think we can commit
it as-is.
Thanks for doing that. Of course, it's fine to not apply the patch as in this case.
http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/less/less/Attic/forwback.c.diff?r1=1.5&r2=1.6&only_with_tag=MAIN&f=h
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=227
1) Size your terminal to 25 lines
2) jot 20 > ~/tmp/20lines.txt
3) jot 100 120 1 > /tmp/20lines.2.txt
4) more /tmp/20lines.*
5) At the prompt, press spacebar to display the second file. The first
file should remain in the scrollback buffer.
Thanks again. I'll check the PR's, other patches, and your test-case will help greatly.
I'll post again when I find a better overall solution.

Cheers! Jamie
Cy Schubert
2017-12-14 17:15:13 UTC
Permalink
IIRC, as I scripted this and haven't looked at it for a long time: LESS=-MMs

---
Sent using a tiny phone keyboard.
Apologies for any typos and autocorrect.
Also, this old phone only supports top post. Apologies.

Cy Schubert
<***@cschubert.com> or <***@freebsd.org>
The need of the many outweighs the greed of the few.
---

-----Original Message-----
From: by
Sent: 06/12/2017 15:03
To: Alan Somers
Cc: freebsd-***@freebsd.org; Jamie Landeg-Jones; FreeBSD CURRENT
Subject: Re: Strange behavior about pattern matching on manual pages [FIXED]
How about just setting MANPAGER=less in your environment?
Because some of us prefer "more"?
And as I said, it's related to searching using the more(1) command generally.
I was under the impression that fixing bugs in existing commands was a better
solution than telling someone to simply use something else.
Yes, it certainly is. Are you sure this is actually a bug in less, or is it just weird-but-intended behavior when less is emulating some old version of more? It would be worth comparing our less sources to upstream's to see what differences have crept in, and svn blaming them to see why.
-Alan
I just test it in FreeBSD 11.1-RELEASE-p5

It works well when I change PAGER=more to PAGER=less before man(1).

And I found more(1) and less(1) is the same thing(they have the same inode number laying in fs), may be just different command name, different behavior.

If it is emulating more(1) behavior by less(1), why not just replace default PAGER=less ?


by
_______________________________________________
freebsd-***@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-***@freebsd.org"
Loading...