On Sun, Oct 16, 2022 at 03:26:45PM +0100, Gavin Smith wrote:
> On Sun, Oct 16, 2022 at 04:58:59PM +0300, Eli Zaretskii wrote:
> > > From: Gavin Smith <[email protected]>
> > > Date: Sun, 16 Oct 2022 14:23:27 +0100
> > > Cc: [email protected]
> > >
> > > I've committed more code to use "man -w" first to check if the man page
> > > exists, before "man -a", in commit 8520d2b4d8.
> >
> > Is the -w option to 'man' portable? According to my Posix references,
> > it isn't.
>
> No, it doesn't exist on Solaris:
>
> https://docs.oracle.com/cd/E26502_01/html/E29030/man-1.html#scrolltoc
>
> It may be more trouble than it's worth to try to account for different
> man versions.
>
> Any other comments before I revert the change?
An improvement would be to check the exit status of "man -a" and if
not found, to fall back to loading the man page as usual.
$ uname -a
SunOS login 5.10 Generic_150400-17 sun4v sparc SUNW,SPARC-Enterprise-T5220
$ man -w foo
usage: man [-] [-adFlrt] [-M path] [-T macro-package ] [ -s section ] name ...
man [-M path] -k keyword ...
man [-M path] -f file ...
$ echo $?
2
$ man foo
No manual entry for foo.
$ echo $?
0
$
This would allow us to keep the performance improvement from using "man -a"
(presumably Hilmar is using it for something and isn't just looking for
problems for no reason).