Re: switch default MANPAGER from more(1) to less(1)

2020-07-20 Thread Ingo Schwarze
Hi,

ropers wrote on Mon, Jul 20, 2020 at 05:54:46AM +0100:

> Ah, I see where you're coming from, Ingo.  You've dropped the idea of
> testing for less(1) in non-portable mandoc because we know less(1) is
> in base.[1]

Configuration testing is never needed in a base system.  It may
sometimes linger when importing third-party software into base,
but even then, it is often deleted.

> I'm not certain I understand why they're passing /dev/null as
> a tagsfile.  Maybe to test if any -T  throws any error?

Exactly, that's what i wrote the HAVE_LESS_T test in mandoc-portable
for: to test whether less(1) has (support for) -T.

> (I also don't actually understand the redirection to file
> descriptor 3.  Cluebats welcome, on- or off-list.)

   $ sed -n /Output/,/3:/p configure
  # Output file descriptor usage:
  # 1 (stdout): config.h, Makefile.local
  # 2 (stderr): original stderr, usually to the console
  # 3: config.log

Anyway, i committed the patch to OpenBSD, thanks to all who provided
feedback.

No need to discuss mandoc-portable on tech@ any further.

Yours,
  Ingo



Re: switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread ropers
Ah, I see where you're coming from, Ingo.  You've dropped the idea of
testing for less(1) in non-portable mandoc because we know less(1) is
in base.[1]

That makes a lot of sense.

Like you said, the idea of testing for less might be worth revisiting
in mandoc-portable.  Admittedly, testing for less there would in fact
be "adding portability goo", which is never entirely cost-free, but
maybe that's justified here?

> Maybe test for the availability of less(1) in ./configure, which is quite 
> easy to do and which ./configure already does for many operating system 
> features. That would also be convenient because the mandoc ./configure is set 
> up in such a way that it is trivial for downstream package maintainers (say 
> in Void Linux, FreeBSD, or Illumos) to manually override in their package any 
> result that ./configure automatically detects.

There presently is a test for less on line 340 in -portable's configure file:

$ cat -n configure | sed -ne '155G; 149,155p; 338,350p'
   149  ismanual() {
   150  [ -z "${3}" ] && return 1
   151  echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&2
   152  echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&3
   153  echo 1>&3
   154  return 0
   155  }

   338  if ismanual "less -T" LESS_T ${HAVE_LESS_T}; then
   339  :
   340  elif less -ET /dev/null test-noop.c 1>/dev/null 2>&3; then
   341  HAVE_LESS_T=1
   342  echo "tested less -T: yes" 1>&2
   343  echo "tested less -T: yes" 1>&3
   344  echo 1>&3
   345  else
   346  HAVE_LESS_T=0
   347  echo "tested less -T: no" 1>&2
   348  echo "tested less -T: no" 1>&3
   349  echo 1>&3
   350  fi

That's slightly more advanced but similar in principle to the silly
little shell-based less test I sent you off-list, though I'm not
certain I understand why they're passing /dev/null as a tagsfile.
Maybe to test if any -T  throws any error?  (I also don't
actually understand the redirection to file descriptor 3.  Cluebats
welcome, on- or off-list.)

Anyway, I think your afore-enumerated advantages notwithstanding,
there's a downside to compile-time testing in that it might leave
someone stranded if the install environment differs, or if users
break their less after the fact but before they figure out they can
get things back to normal via PAGER variables, etc.  Not that that
sounds like anyone I know (*cough*).

But I will add, HOLY PAPER[2], I didn't even realise fixing this would
also drastically improve man usability on OpenBSD itself, where of
course it all hinges on this too.  That crazy pseudo-more, pseudo-less
behaviour where man kind of acts like less in that less keys work, but
if you reach the bottom of the man page via 'j' or space or Ctrl-f, it
throws you out, which less normally doesn't?  Yeah, that's all gone
now.  Or, it is once more -s is banished.[3]  I thought that man
behaviour was par for the course, but it doesn't have to be.  And
legit less-paged man feels so much nicer and faster, especially on a
not-so-well supported console.  Space and Ctrl+f and Ctrl+b are so
much more responsive now.[4]  Speeed!  Especially Ctrl+b.  Gotta go
fast!  It didn't hit me before your email how this little tangential
-portable thing points back to OpenBSD man behaviour, which is a BIG
part of the out-of-the-box OpenBSD[5] user experience and superficial
newbie-friendliness.
Thank you!  Great stuff!

Ian

footnotes:
[1] And that's just one more benefit to controlling the environment
and providing a complete operating system instead of drinking the
distro juice.
[2] 
[3] Fellow newbies note:
To test, run man man, then Ctrl+z and  ps ax|egrep '[m]ore|[l]ess'  to
see what actually runs, then fg.  Btw., seriously, "more -s -T"?  more
isn't even supposed to have a -T option.  I know it's the same
executable, but man, make up your mind!  Whoever you choose to be,
we'll respect you, more or less. Anyhoo, check export -p and run
export PAGER=/usr/bin/less.  unset PAGER to reverse (also check
MANPAGER in case of probs).
[4] The only niggle there is that if you page past an article's end,
less doesn't stop at the cliff edge but gives you vi-like tilde-filed
empty lines, even if the article is longer than a whole page.  I'm not
sure if that's a bug or feature since it preserves page up/down
alignment, but other implementations stop and realign themselves at
the bottom.  "Started from the bottom, now we here."
Oh, and the only *other* niggle is that help, i.e. man help now
doesn't auto-exit either, but what noob would not figure out to press
q to exit?  So I'm not sure this needs to be mentioned on help.1, but
maybe?
Also, as the *other* other niggle, should the contents of of the man
page be kept onscreen when less-paged man exits?  They are on console,
but not in xterm.  Is that even something related to this or would
harmonising that require kernel wscons driver hacking?
[5] 

Re: switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread Ingo Schwarze
Hi Jason & Theo,

thanks for the feedback!

Jason McIntyre wrote on Sun, Jul 19, 2020 at 05:02:02PM +0100:

> i guess the argument in favour of more(1) would be that it is part of
> posix, even if optional, where less(1) is not. so it makes sense to
> choose a command most likely to work on most machines.
> 
> having said that, i've nothing against the switch. i imagine it'd be
> hard to find a system without less(1).

I was only talking about mandoc in OpenBSD.  I rarely ask questions
about mandoc-portable on , and i rarely decide
what to do in mandoc-portable before things are committed to
OpenBSD.

It does indeed seem hard to find an OpenBSD system without less(1).  :)

Not yet sure what i will do in -portable.  Maybe test for the
availability of less(1) in ./configure, which is quite easy to do
and which ./configure already does for many operating system features.
That would also be convenient because the mandoc ./configure is set
up in such a way that it is trivial for downstream package maintainers
(say in Void Linux, FreeBSD, or Illumos) to manually override in
their package any result that ./configure automatically detects.
But that does not need to bother anyone here.  None of the (very
small amount of) portability code is in our OpenBSD CVS tree.

> about -s: it's inclusion probably comes from a time when there was an
> annoying bug in nroff that made our man pages randomly display a number
> of blank lines in the middle of a page. -s mitigated that somewhat.

Ah.  Good to know.  Then that's definitely no longer needed.

Thanks,
  Ingo



Re: switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread Theo de Raadt
> about -s: it's inclusion probably comes from a time when there was an
> annoying bug in nroff that made our man pages randomly display a number
> of blank lines in the middle of a page. -s mitigated that somewhat.

that is also what I recall.



Re: switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread Jason McIntyre
On Sun, Jul 19, 2020 at 05:36:34PM +0200, Ingo Schwarze wrote:
> Hi,
> 
> currently, if neither the MANPAGER nor the PAGER environment variable
> is set, man(1) uses "more -s" as the manual page pager.  I am quite
> sure that the only reason i did this is that i thought this behaviour
> was required by POSIX.
> 
> But it is not:
> 
>   https://pubs.opengroup.org/onlinepubs/9699919799/utilities/man.html
> 
>   "If the PAGER variable is null or not set,
>the command shall be either "more" or another
>paginator utility documented in the system documentation."
> 
> Right now, i even failed to find any indication that POSIX ever
> required more(1) as the default for this purpose.  I no longer
> understand where i got that idea from in the first place.
> 
> That said, on OpenBSD, the pager we provide is less(1).  In effect,
> it is less(1) even when called as more(1), albeit with minor
> differences in the default behaviour.  On top of that, our man(1)
> utility heavily relies on less(1) features that tradional more(1)
> wouldn't even have, in particular tagging support (:t).
> 
> So, i would find it logical to use less(1) as the default pager
> instead of more(1).
> 
> Same thing for the "-s" option: i thought it was required by POSIX,
> but it isn't.  I also provides little benefit, if any, and it may
> occasionally break output, in the rare case where two consecutive
> blank lines are syntacically significant (for example in an EXAMPLES
> section presenting a code sample).  Besides, if the author deliberately
> chose to put two consecutive blank lines, i don't see why man(1)
> should squeeze them and override the author's intent.
> 
> Is anybody concerned about the following patch, or would you agree
> with it?
> 
> Yours,
>   Ingo
> 

hi.

i guess the argument in favour of more(1) would be that it is part of
posix, even if optional, where less(1) is not. so it makes sense to
choose a command most likely to work on most machines.

having said that, i've nothing against the switch. i imagine it'd be
hard to find a system without less(1).

about -s: it's inclusion probably comes from a time when there was an
annoying bug in nroff that made our man pages randomly display a number
of blank lines in the middle of a page. -s mitigated that somewhat.

jmc

> 
> Index: apropos.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/apropos.1,v
> retrieving revision 1.41
> diff -u -p -r1.41 apropos.1
> --- apropos.1 22 Nov 2018 12:32:10 -  1.41
> +++ apropos.1 19 Jul 2020 15:18:30 -
> @@ -340,7 +340,7 @@ types appearing in function arguments in
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 ;
> +.Xr less 1 ;
>  see
>  .Xr man 1
>  for details.
> @@ -363,7 +363,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is not defined.
>  If neither PAGER nor MANPAGER is defined,
> -.Xr more 1
> +.Xr less 1
>  .Fl s
>  is used.
>  Only used if
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/mandoc/main.c,v
> retrieving revision 1.253
> diff -u -p -r1.253 main.c
> --- main.c15 Jun 2020 17:25:03 -  1.253
> +++ main.c19 Jul 2020 15:18:31 -
> @@ -1194,7 +1194,7 @@ spawn_pager(struct outstate *outst, char
>   if (pager == NULL || *pager == '\0')
>   pager = getenv("PAGER");
>   if (pager == NULL || *pager == '\0')
> - pager = "more -s";
> + pager = "less";
>   cp = mandoc_strdup(pager);
>  
>   /*
> Index: man.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/man.1,v
> retrieving revision 1.37
> diff -u -p -r1.37 man.1
> --- man.1 17 Jun 2020 19:41:25 -  1.37
> +++ man.1 19 Jul 2020 15:18:31 -
> @@ -275,7 +275,7 @@ is case insensitive.
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 .
> +.Xr less 1 .
>  If
>  .Xr less 1
>  is used, the interactive
> @@ -329,7 +329,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is not defined.
>  If neither PAGER nor MANPAGER is defined,
> -.Xr more 1
> +.Xr less 1
>  .Fl s
>  is used.
>  .El
> Index: mandoc.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
> retrieving revision 1.168
> diff -u -p -r1.168 mandoc.1
> --- mandoc.1  15 Jun 2020 18:05:25 -  1.168
> +++ mandoc.1  19 Jul 2020 15:18:31 -
> @@ -650,7 +650,7 @@ It never affects the interpretation of i
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 ;
> +.Xr less 1 ;
>  see
>  .Xr man 1
>  for details.
> @@ -664,7 +664,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is 

Re: switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread Theo de Raadt
Good.

The user-interface of less is slightly more refined, and definately
preferred.

Ingo Schwarze  wrote:

> Hi,
> 
> currently, if neither the MANPAGER nor the PAGER environment variable
> is set, man(1) uses "more -s" as the manual page pager.  I am quite
> sure that the only reason i did this is that i thought this behaviour
> was required by POSIX.
> 
> But it is not:
> 
>   https://pubs.opengroup.org/onlinepubs/9699919799/utilities/man.html
> 
>   "If the PAGER variable is null or not set,
>the command shall be either "more" or another
>paginator utility documented in the system documentation."
> 
> Right now, i even failed to find any indication that POSIX ever
> required more(1) as the default for this purpose.  I no longer
> understand where i got that idea from in the first place.
> 
> That said, on OpenBSD, the pager we provide is less(1).  In effect,
> it is less(1) even when called as more(1), albeit with minor
> differences in the default behaviour.  On top of that, our man(1)
> utility heavily relies on less(1) features that tradional more(1)
> wouldn't even have, in particular tagging support (:t).
> 
> So, i would find it logical to use less(1) as the default pager
> instead of more(1).
> 
> Same thing for the "-s" option: i thought it was required by POSIX,
> but it isn't.  I also provides little benefit, if any, and it may
> occasionally break output, in the rare case where two consecutive
> blank lines are syntacically significant (for example in an EXAMPLES
> section presenting a code sample).  Besides, if the author deliberately
> chose to put two consecutive blank lines, i don't see why man(1)
> should squeeze them and override the author's intent.
> 
> Is anybody concerned about the following patch, or would you agree
> with it?
> 
> Yours,
>   Ingo
> 
> 
> Index: apropos.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/apropos.1,v
> retrieving revision 1.41
> diff -u -p -r1.41 apropos.1
> --- apropos.1 22 Nov 2018 12:32:10 -  1.41
> +++ apropos.1 19 Jul 2020 15:18:30 -
> @@ -340,7 +340,7 @@ types appearing in function arguments in
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 ;
> +.Xr less 1 ;
>  see
>  .Xr man 1
>  for details.
> @@ -363,7 +363,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is not defined.
>  If neither PAGER nor MANPAGER is defined,
> -.Xr more 1
> +.Xr less 1
>  .Fl s
>  is used.
>  Only used if
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/mandoc/main.c,v
> retrieving revision 1.253
> diff -u -p -r1.253 main.c
> --- main.c15 Jun 2020 17:25:03 -  1.253
> +++ main.c19 Jul 2020 15:18:31 -
> @@ -1194,7 +1194,7 @@ spawn_pager(struct outstate *outst, char
>   if (pager == NULL || *pager == '\0')
>   pager = getenv("PAGER");
>   if (pager == NULL || *pager == '\0')
> - pager = "more -s";
> + pager = "less";
>   cp = mandoc_strdup(pager);
>  
>   /*
> Index: man.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/man.1,v
> retrieving revision 1.37
> diff -u -p -r1.37 man.1
> --- man.1 17 Jun 2020 19:41:25 -  1.37
> +++ man.1 19 Jul 2020 15:18:31 -
> @@ -275,7 +275,7 @@ is case insensitive.
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 .
> +.Xr less 1 .
>  If
>  .Xr less 1
>  is used, the interactive
> @@ -329,7 +329,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is not defined.
>  If neither PAGER nor MANPAGER is defined,
> -.Xr more 1
> +.Xr less 1
>  .Fl s
>  is used.
>  .El
> Index: mandoc.1
> ===
> RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
> retrieving revision 1.168
> diff -u -p -r1.168 mandoc.1
> --- mandoc.1  15 Jun 2020 18:05:25 -  1.168
> +++ mandoc.1  19 Jul 2020 15:18:31 -
> @@ -650,7 +650,7 @@ It never affects the interpretation of i
>  Any non-empty value of the environment variable
>  .Ev MANPAGER
>  is used instead of the standard pagination program,
> -.Xr more 1 ;
> +.Xr less 1 ;
>  see
>  .Xr man 1
>  for details.
> @@ -664,7 +664,7 @@ Specifies the pagination program to use 
>  .Ev MANPAGER
>  is not defined.
>  If neither PAGER nor MANPAGER is defined,
> -.Xr more 1
> +.Xr less 1
>  .Fl s
>  is used.
>  Only used if
> 



switch default MANPAGER from more(1) to less(1)

2020-07-19 Thread Ingo Schwarze
Hi,

currently, if neither the MANPAGER nor the PAGER environment variable
is set, man(1) uses "more -s" as the manual page pager.  I am quite
sure that the only reason i did this is that i thought this behaviour
was required by POSIX.

But it is not:

  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/man.html

  "If the PAGER variable is null or not set,
   the command shall be either "more" or another
   paginator utility documented in the system documentation."

Right now, i even failed to find any indication that POSIX ever
required more(1) as the default for this purpose.  I no longer
understand where i got that idea from in the first place.

That said, on OpenBSD, the pager we provide is less(1).  In effect,
it is less(1) even when called as more(1), albeit with minor
differences in the default behaviour.  On top of that, our man(1)
utility heavily relies on less(1) features that tradional more(1)
wouldn't even have, in particular tagging support (:t).

So, i would find it logical to use less(1) as the default pager
instead of more(1).

Same thing for the "-s" option: i thought it was required by POSIX,
but it isn't.  I also provides little benefit, if any, and it may
occasionally break output, in the rare case where two consecutive
blank lines are syntacically significant (for example in an EXAMPLES
section presenting a code sample).  Besides, if the author deliberately
chose to put two consecutive blank lines, i don't see why man(1)
should squeeze them and override the author's intent.

Is anybody concerned about the following patch, or would you agree
with it?

Yours,
  Ingo


Index: apropos.1
===
RCS file: /cvs/src/usr.bin/mandoc/apropos.1,v
retrieving revision 1.41
diff -u -p -r1.41 apropos.1
--- apropos.1   22 Nov 2018 12:32:10 -  1.41
+++ apropos.1   19 Jul 2020 15:18:30 -
@@ -340,7 +340,7 @@ types appearing in function arguments in
 Any non-empty value of the environment variable
 .Ev MANPAGER
 is used instead of the standard pagination program,
-.Xr more 1 ;
+.Xr less 1 ;
 see
 .Xr man 1
 for details.
@@ -363,7 +363,7 @@ Specifies the pagination program to use 
 .Ev MANPAGER
 is not defined.
 If neither PAGER nor MANPAGER is defined,
-.Xr more 1
+.Xr less 1
 .Fl s
 is used.
 Only used if
Index: main.c
===
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.253
diff -u -p -r1.253 main.c
--- main.c  15 Jun 2020 17:25:03 -  1.253
+++ main.c  19 Jul 2020 15:18:31 -
@@ -1194,7 +1194,7 @@ spawn_pager(struct outstate *outst, char
if (pager == NULL || *pager == '\0')
pager = getenv("PAGER");
if (pager == NULL || *pager == '\0')
-   pager = "more -s";
+   pager = "less";
cp = mandoc_strdup(pager);
 
/*
Index: man.1
===
RCS file: /cvs/src/usr.bin/mandoc/man.1,v
retrieving revision 1.37
diff -u -p -r1.37 man.1
--- man.1   17 Jun 2020 19:41:25 -  1.37
+++ man.1   19 Jul 2020 15:18:31 -
@@ -275,7 +275,7 @@ is case insensitive.
 Any non-empty value of the environment variable
 .Ev MANPAGER
 is used instead of the standard pagination program,
-.Xr more 1 .
+.Xr less 1 .
 If
 .Xr less 1
 is used, the interactive
@@ -329,7 +329,7 @@ Specifies the pagination program to use 
 .Ev MANPAGER
 is not defined.
 If neither PAGER nor MANPAGER is defined,
-.Xr more 1
+.Xr less 1
 .Fl s
 is used.
 .El
Index: mandoc.1
===
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.168
diff -u -p -r1.168 mandoc.1
--- mandoc.115 Jun 2020 18:05:25 -  1.168
+++ mandoc.119 Jul 2020 15:18:31 -
@@ -650,7 +650,7 @@ It never affects the interpretation of i
 Any non-empty value of the environment variable
 .Ev MANPAGER
 is used instead of the standard pagination program,
-.Xr more 1 ;
+.Xr less 1 ;
 see
 .Xr man 1
 for details.
@@ -664,7 +664,7 @@ Specifies the pagination program to use 
 .Ev MANPAGER
 is not defined.
 If neither PAGER nor MANPAGER is defined,
-.Xr more 1
+.Xr less 1
 .Fl s
 is used.
 Only used if