mbornet-hl / hl

Highlight (colorize) text data using regular expressions (efficient C program)
Other
118 stars 9 forks source link

man no longer uses a pager #10

Closed dfaure-kdab closed 4 years ago

dfaure-kdab commented 7 years ago

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.

mbornet-hl commented 7 years ago

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.

dfaure-kdab commented 7 years ago

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?

mbornet-hl commented 7 years ago

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

dfaure-kdab commented 7 years ago

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

Implemented in https://github.com/mbornet-hl/hl/pull/11

mbornet-hl commented 7 years ago

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

mbornet-hl commented 4 years ago

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

mbornet-hl commented 4 years ago

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.

dfaure-kdab commented 4 years ago

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