aitjcize / cppman

C++ 98/11/14 manual pages for Linux/MacOS
GNU General Public License v3.0
1.27k stars 79 forks source link

Don't overwrite existing manpages with -m true #98

Open jyn514 opened 5 years ago

jyn514 commented 5 years ago

cppman -m true -c overwrites pages that already exist, like memcpy and malloc, without checking. It would be nice to keep those versions, especially since they have some info that the C++ manuals don't (e.g. thread safety).

jyn514 commented 5 years ago

Looks like this could go in https://github.com/aitjcize/cppman/blob/master/cppman/main.py#L184, I might take a stab at it

aitjcize commented 5 years ago

Can you try adjust your MANPATH ? If you put the default MANPATH before cppman man path, it should find the system builtin man pages first.

jyn514 commented 5 years ago

Would it be possible for cppman to write it in ~/.manpath when run with -m? Normally I leave $MANPATH unset and just use the defaults returned by manpath

SGSSGene commented 5 years ago

Would it be possible for cppman to write it in ~/.manpath when run with -m? Normally I leave $MANPATH unset and just use the defaults returned by manpath

That is exactly what cppman does. Cppman does not overwrite any system manuals. It only adjust the ~/.manpath.

This sounds like the same issue as #91 . I am not sure where it comes from. I also can't reproduce it. If you have any hint how to reproduce it, I would be very thankful.

jyn514 commented 5 years ago

~/.manpath takes precedence over other man pages. For example manpath returns /home/joshua/.node/share/man:/home/joshua/.local/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man on my machine. $MANPATH is unset and ~/.manpath contains MANDATORY_MANPATH /home/joshua/.local/share/man.

I would like ~/.manpath not to take precedence. Maybe run manpath and append ~/.local/share/man to the end of that.

SGSSGene commented 5 years ago

I have finally been able to reproduce it. The program manpath does a lot of magic. I looked into the source code to understand precisely what is being done in which order, but now I am more confused than ever. (Also it reassures me that C++ is the simpler language to read ;-) ).

What I am certain about is, that the different results come from the $PATH variable, which is being processed in manpath. On one of my systems $PATH is set to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin On the other system it is set to /home/q/bin:/home/q/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

The important part is the extra /home/q/.local/bin on one system compared to the other one. manpath checks all paths in $PATH extended by ".", "../man" and "../share/man", which leads to finding /home/q/.local/share/man much earlier and setting it at the beginning of the results. While on the other system where /home/q/.local/bin is not present, it will be added much later in the process.

This also means manpath will find the cppman pages on your system independently of the entry in ~/.manpath. I don't know how to deal with this issue.

ghost commented 3 years ago

To begin with, I suggest using 3cpp as prefix instead of 3 to distinguish cpp pages. This should help with overriding pages.

Now, whatever cppman -m true is supposed to do, it doesn't, because the output of manpath stays the same. So I set it manually in shellrc: export MANPATH="$(manpath -g):$HOME/.cache/cppman". I suggest adding this to readme.

matu3ba commented 3 years ago

I cant confirm the bug on an Arch derivate from executing :Man inside neovim. Instead I get the autogenerated template pages loading.