Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

man: not all man pages are listed if MANPATH environment is set #73

Open
yuwata opened this issue Aug 30, 2016 · 5 comments · May be fixed by #74
Open

man: not all man pages are listed if MANPATH environment is set #73

yuwata opened this issue Aug 30, 2016 · 5 comments · May be fixed by #74

Comments

@yuwata
Copy link

yuwata commented Aug 30, 2016

If MANPATH environment is set, only man pages located under directories specified by MANPATH are shown.

e.g.,

$ echo $MANPATH
/usr/share/man/openmpi-x86_64:/usr/share/lmod/lmod/share/man::
$ man ma(tab)
(no output)
$ man MPI(tab)
MPI
MPI_Abort
(snip)

$ unset MANPATH
$ man ma(tab)
mac2unix
machinectl
(snip)
$ man MPI(tab)
(no output)

As explained in manpath.1

If $MANPATH is set, manpath displays its value rather than determining it on the fly. If $MANPATH is prefixed by a colon, then the value of the variable is appended to the list determined from the content of the configuration files. If the colon comes at the end of the value in the variable, then the determined list is appended to the content of the variable. If the value of the variable contains a double colon (::), then the determined list is inserted in the middle of the value, between the two colons.

I think in the completion for man should use the output of manpath command.

I found this issue on Fedora 24 with Lmod package.

yuwata added a commit to yuwata/bash-completion that referenced this issue Sep 5, 2016
yuwata added a commit to yuwata/bash-completion that referenced this issue Sep 5, 2016
@ackalker
Copy link

ackalker commented Nov 2, 2016

Sadly, the suggested fix doesn't work with the mdocml package installed by default in Void Linux, which has neither a manpath command nor a -w option to man (which in this case is a symlink to mandoc). In this case I see no other solution but to process both /etc/man.conf and the MANPATH variable when completing.

@ackalker
Copy link

ackalker commented Nov 2, 2016

Actually, there is another way to get completion candidates (including manual pages in directories in user-supplied MANPATH) using mdocml's apropos command with a regex.
To get all completion candidates for the prefix perlc:

$ echo $MANPATH
:/home/miki/perl5/man/
$ apropos 'Nm~^perlc'|sed -e 's/(.*$//'
perlcall
perlce
perlcheat
perlclib
perlcn
perlcommunity
perlcritic
perlcygwin

Note that this includes the candidate perlcritic, which comes from the corresponding Perl module which I installed locally in /home/miki/perl5. For this to work I needed to run makewhatis as regular user, to create the database /home/miki/perl5/man/mandoc.db, which is used by apropos.

tornaria added a commit to tornaria/bash-completion that referenced this issue Apr 16, 2017
See scop#73.

The old code attempts to guess manual names from filenames, but this has
a few drawbacks. On one hand the logic to determine the manpath was
incorrect, as explained in scop#73. On the other hand, not all manual names
correspond to filenames. Both issues are subtle and non-portable as the
exact semantics vary from one man program to another.

The new code uses "man -k" to find potential completions. This method
seems portable and it should be correct -- as long as the man database
is up to date.

The one delicate detail is parsing the output of "man -k". The proposed
version works ok at least with both man-db and mdocml packages.
tornaria added a commit to tornaria/bash-completion that referenced this issue Apr 18, 2017
This includes two tests expected to fail:

a. The logic to determine the manpath is incorrect (see scop#73)

b. Not all manual names correspond to filenames
tornaria added a commit to tornaria/bash-completion that referenced this issue Apr 18, 2017
Fixes scop#73.

The old code attempts to guess manual names from filenames, but this has
a few drawbacks. On one hand the logic to determine the manpath was
incorrect, as explained in scop#73. On the other hand, not all manual names
correspond to filenames. Both issues are subtle and non-portable as the
exact semantics vary from one man program to another.

The new code uses "man -k" to find potential completions. This method
seems portable and it should be correct -- as long as the man database
is up to date.

The one delicate detail is parsing the output of "man -k". The proposed
version works ok at least with both man-db and mdocml packages.

The issue with manual names not corresponding to filenames is still
broken with man-db, but it seems their bug. It is fixed with mdocml.
tornaria added a commit to tornaria/bash-completion that referenced this issue May 7, 2017
This includes two tests expected to fail:

a. The logic to determine the manpath is incorrect (see scop#73)

b. Not all manual names correspond to filenames
tornaria added a commit to tornaria/bash-completion that referenced this issue May 7, 2017
Fixes scop#73.

The old code attempts to guess manual names from filenames, but this has
a few drawbacks. On one hand the logic to determine the manpath was
incorrect, as explained in scop#73. On the other hand, not all manual names
correspond to filenames. Both issues are subtle and non-portable as the
exact semantics vary from one man program to another.

The new code uses "man -k" to find potential completions. This method
seems portable and it should be correct -- as long as the man database
is up to date.

The one delicate detail is parsing the output of "man -k". The proposed
version works ok at least with both man-db and mdocml packages.

The issue with manual names not corresponding to filenames is still
broken with man-db, but it seems their bug. It is fixed with mdocml.
tornaria added a commit to tornaria/bash-completion that referenced this issue Jul 3, 2017
This includes two tests expected to fail:

a. The logic to determine the manpath is incorrect (see scop#73)

b. Not all manual names correspond to filenames
tornaria added a commit to tornaria/bash-completion that referenced this issue Jul 3, 2017
Fixes scop#73.

The old code attempts to guess manual names from filenames, but this has
a few drawbacks. On one hand the logic to determine the manpath was
incorrect, as explained in scop#73. On the other hand, not all manual names
correspond to filenames. Both issues are subtle and non-portable as the
exact semantics vary from one man program to another.

The new code uses "man -k" to find potential completions. This method
seems portable and it should be correct -- as long as the man database
is up to date.

The one delicate detail is parsing the output of "man -k". The proposed
version works ok at least with both man-db and mdocml packages.

The issue with manual names not corresponding to filenames is still
broken with man-db, but it seems their bug. It is fixed with mdocml.
@tornaria
Copy link
Contributor

tornaria commented Jul 3, 2017

A fix is in 2af2986 (see PR #116), using man -k.

Tested to work with both with man-db and with mdocml. Indeed the PR creates a number of new test cases which include a test for this bug.

@inconstante
Copy link
Contributor

I think that commit ID e6a4715 fixes this problem. Can this bug be closed?

@tornaria
Copy link
Contributor

tornaria commented Apr 1, 2018

It doesn't, as explained above. In my system (void linux, which uses mdocml as man)

$ manpath
bash: manpath: command not found
$ man -w
usage: man [-acfhklw] [-C file] [-M path] [-m path] [-S subsection]
	   [[-s] section] name ...

So essentially the manpath becomes hardcoded.

There is a more robust fix including tests for this and other cases in PR #116.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants