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 <tagsfile> 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] <https://www.youtube.com/watch?v=l1dnqKGuezo>
[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] Don't ever get caught transposing the last two letters of OpenBSD
like I just did here before catching and correcting it.  Because that
would be illegal advocacy in several U.S. companies and states.
They've laws against that sort of thing.
(*cough*) echo OpenBSD | sed -E 's/(.*)(.)(.)/\1\3\2/'
(*cough*) echo go kwiq | \
awk '{print$1,toupper($2)}' | sed -E 's/(.*)(.)(.)/\1\3/' | tr [B-] [A-]

Reply via email to