mbornet-hl/hl

man no longer uses a pager

Closed this issue · 8 comments

hl/hl_bin/man colorizes the output of man, but loses the use of a pager. So the full man page gets printed out, while standard man would use a pager like less to make it possible to read it page by page, go up, etc.
Of course one can work around it by piping hl_bin/man to less, but it would be more convenient if the use of hl was fully transparent.

In fact, this appears to fix it:

--- i/hl_bin/man
+++ w/hl_bin/man
@@ -45,8 +45,9 @@ if [ "$USE_HL" = "no" ]; then
 else
        # Default behaviour : colorization
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-       hl -u --"$progname" < "$ERR" & hl --"$progname" < "$OUT" & \
-               "$progname" "$@" > "$OUT" 2> "$ERR"
+       hl -u --"$progname" < "$ERR" &
+       ( hl --"$progname" < "$OUT" | less ) &
+       "$progname" "$@" > "$OUT" 2> "$ERR"
 
        rc=$?

I'm not sure why the original syntax is a & b & c when the & means "detach", not "and". So it would be equivalent and more readable to do this on three lines anyway.

I guess my patch needs to be improved to not hardcode less and instead do like man does:
$MANPAGER, defaulting to $PAGER, defaulting to ... no idea, more, I guess?
In my case $PAGER is less.

Hi David
you're right, I noticed this problem some time ago, and that's why I wrote a new pager : https://github.com/mbornet-hl/hl/blob/master/scripts/hl_man_pager . The link "man" in the hl_bin directory should not be used, since it's not conveniant, and you should use : MANPAGER=/usr/local/bin/hl_man_pager instead (or something like that, depending on where the hl_man_pager script resides).
Regarding the & , you're right, it means detach, and that is what I intend to do. It's the only way I found to pipe stdout to one process (hl) and stderr to another process (hl once again in this case, possibly with different configuration options, but I had no time to finish). I wanted to be able to colorize differently stdout and stderr. If you find a better way to create two pipes (one for stdout and one for stderr, going to two different processes, in the shell language), please let me know, I would be very interested in it.
I think your problem is solved with these informations, so I close this issue.

If hl_bin/man shouldn't be used, why not remove it?

If MANPAGER should be set, why not mention that in some setup instructions?

Just because I'm working on another project, and because I'm very busy as I already told you.

That's no reason to close the issue, it was valid ;-)

Implemented in #11

Re-opened for David as long as corrections haven't been done.

The 'man' link has been removed from hl_bin, and a light documentation has been added to the wiki.

Hi David,
I've accidentally discarded with your pull request.
Could you please make your changes again (INSTALL.txt and hl_man) so that I can merge them to the main branch ?
Thanks.

I lost interest in hl because of the bugs and regressions. Please feel free to take over those changes.