-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support compressed man-pages #2298
Conversation
When `man` is available, we'll only pass the name of the page instead of the full path, so `man` can find the page, compressed or not. The behaviour stays the same (display txt version) if `man` is not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, but please help me understand first:
- what creates compressed man pages?
- how are their filenames called?
- how does hub's current help system (e.g.
hub help hub
) not support compressed pages?
I think the effort to fix this is worthwhile (especially if we can simplify the overall approach) but let's first try to make the diff smaller, otherwise I feel that this change is risky.
@@ -54,6 +54,7 @@ install_test() { | |||
|
|||
[ -z "$HUB_COVERAGE" ] || script/coverage prepare | |||
script/build | |||
make man-pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we strictly need man pages to be built during tests. We can work around it.
|
||
# Requires man-pages to be built | ||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
MAN_DIR="$DIR/../../../share/man/man1/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the additions to this fake man
executable are superfluous. The only point of this executable is to log its invocation to .history
so that the tests can verify that man
was called and with what arguments. I don't think that it should try have any output or perform any logic.
Hey thanks for taking the time.
Not sure what distro compresses their man-pages, I took the information from the bug issue #2228 and verified that
Just like usual, only with the added compression suffix, like
Currently, hub only searches for But thinking about it again, I have another possible solution: To reduce the amount of changes, we could remove the searching responsibility from Thoughts/disadvantages that come to mind:
Anyway I hope this helped you, let me know if I can help further |
Most linux distributions will have a post-process step on any packaged man pages, which runs, for example,
Always the same directory and filename as the current version of the manpage, except with a file extension denoting the compression format.
As I initially specified in #2228, |
@venyii, thanks for working on this!
From the
It's not picky, users are permitted to paint the bikeshed any color they like. :)
I would favor this option, since it seems to be what the
Again, compressed man pages are no different from uncompressed ones, they go in the same default search directory path except the file extensions denote their compressed status.
You could look at the currently supported list in https://git.savannah.gnu.org/cgit/man-db.git/tree/include/comp_src.h.in It depends on how your distro has configured man-db.
Even if it is uncompressed, you wouldn't want to read it with |
Thank you for taking the time to explain things to me. I'm trying to remember why I made the current help logic way more complicated than it should have been. Basically, running However, there are scenarios where simply delegating to
In any case, I'm definitely up for simplifying the approach: let's delegate as much as we can to |
@venyii Thank you for the work in this PR. I've decided to go a different route, most notably a simpler approach (just call @eli-schwartz Thank you for your thoughts 🙇 |
@mislav Thanks, that looks like it should work nicely. Looking forward to trying out the new release. |
Hey thanks for the PR @mislav and sorry for the inactivity, I was sick some time and didn't have a clear solution yet after the more detailed discussion. But I'm glad that this PR at least helped a bit! |
Fixes #2228
This PR lets
man
handle the search for man-pages, so it doesn't matter if they're uncompressed, .gz, .bz2, etc. Instead of passing the full path toman
, it will only pass the man-page name (e.g.hub-sync
). Searching for local man-page files remains unchanged ifman
is not installed.It took me some time to understand how everything works together with my changes, e.g.
cmd.Exec
replacing the current process (at least on mac),man
not exiting with code16
on every platform if the page couldn't be found, and the wholefakebin
stuff, so I might've missed something that would've made things easier for me :POpen questions
fakebin/man
and the test scenarios:When initially running the test suite (after my changes), the scenario for getting help for a command didn't work anymore since
man
is replaced by the minimalfakebin/man
script which didn't do anything special. Even if the originalman
was the one being used, it wouldn't find any installed man-pages, and sincecmd.Exec
replaces the current process, thecmd.HelpText()
code won't ever be reached (as far as my tests showed). Previously this code was invoked in the error case when the local man-page file couldn't be found (which happened before running theman
cmd).So for now I added generating man-pages to the test script (the only ready-to-use "man-page" that is shipped with the repo is the
hub.1.md
file) and did some changes to imitate the originalman
binary to get the tests working again for all commands/subcommands.I'm not sure this is the best solution (always building man-pages in that case), so I'm open for other ideas if this PR is heading in the right direction.
I hope what I wrote here makes sense or is at least somewhat understandable :P
Thanks!
PS: I also thought about running sth. like
before running the actual command just to see if it exits with an error so I could return that error and fall back to
cmd.HelpText()
, but didn't really like running the command basically twice. Maybe you have a different opinion :)