-
Notifications
You must be signed in to change notification settings - Fork 56
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
Pager help pages are broken on Windows #166
Comments
Incidentally, it seems that not all help pages are broken, only some. I am attaching the Executing |
Did it used to work ? Is it maybe the new UTF-8 stuff of fab6ffa that trip things out ? |
So the discussion about the removal of this was there. |
Thanks. I went over the discussion but I could not quite understand why |
As mentioned in the release notes this was removed and instead I'm starting to think that the bug is rather in the interaction of |
|
Thanks for identifying this issue… I ran into it a while ago and I thought I was getting completely crazy because it would work sometimes and sometimes not. If |
So that rather looks like one of these:
Is there maybe any line translation business occurring that should not be happening ? |
I'm not too familiar with Windows, but from last time I used it there were several terminal implementations there, including |
It doesn't look like it is an issue with the terminal emulator itself, but rather with the command interpreter (used by |
According to this https://ss64.com/nt/syntax-redirection.html pipes with external commands create their own instances of cmd.exe. If cmd.exe acts as both terminal emulator and shell I'm not sure how well that will work. |
Thanks, perhaps one (or more) of these issues may be playing a role. Taking a step back, could someone spell what what are the advantages of not passing |
TypographySo, groff/grotty are able to change text attributes (bold, italic, colors). To the best of my knowledge, Cmdliner only outputs bold and underlined (or italic?).
In our case,
The conservative option is to keep using After some more digging, it seems that this is the solution chosen and somewhat documented by Arch Linux and Debian. They disable SGR output from grotty and fake colors by tweaking the pager.
What we could also do is default to The I think I misunderstood previously that groff has the capability of outputting colors, but the ones I was seeing were because of tweaks as the wiki describes, applied to the "old output format", not directly from the groff document--because Cmdliner doesn't produce colors. Sorry for the confusion. I guess for simple typographic purposes we can switch back to "old output format" and we don't need SGR codes (unless using Windows's Windows hangRegarding the issue at hand, the hang can be reproduced on Windows with any terminal. The invocation below, in a Cygwin bash shell (Cygwin 3.4.3, groff 1.22.4, less 590, Windows 22H2), hangs. The help.groff file. cmd /C 'groff -m man -K utf8 -T utf8 <help.groff | less -R' # hangs
cmd /C 'groff -m man -K utf8 -T utf8 -P-c <help.groff | less' # hangs
cmd /C 'groff -m man -K utf8 -T utf8 -P-c <help.groff | less -R' # hangs
cmd /C 'groff -m man -K utf8 -T utf8 <help.groff | more.com' # doesn't hang
cmd /C 'groff -m man -K utf8 -T utf8 -P-c <help.groff | more.com' # doesn't hang, but no formatting Using a intermediary file never hangs, but prints the name of the file in the pager. cmd /C 'groff -m man -K utf8 -T utf8 <help.groff >help.tty && less -R help.tty' I don't know what's happening. I can bisect next week if needed. |
Thanks @MisterDA for the summary, it would be great if you can investigate the Windows hangs. Also maybe someone like @dra27 has a suspicion (see "Windows hang" in the preceding message) ?
Note that in 1de3611 I tried to add a more brittle way to do that to solve #167 so it would be good to test the hanging invocations with the new invocations. Basically:
|
To me this seems the most robust way of fixing the issue. Isn't there a way to avoid showing the temporary file name in the output? |
Answering to myself: yes, there is an easy way; just replace
becomes
Except for the extra temporary file |
We could do that but I have to say that it annoys me that we are not able to understand what is happening. Reading around, isn't maybe the problem an operator precedence issue ? Does any of the following maybe work ?
|
Maybe the output of
They don't. |
I also read that part but eventually rather understood that the syntax on the left hand-side might need escaping. Other bits on the internet actually seemed to indicate that |
You are probably right. And in any case it doesn't explain the present issue because
|
An interesting data point: the hanging only seems to happen when the help page is longer than a single screenful. If it fits in a single screen, it doesn't hang. |
Something like that seem to be mentioned at the end of this answer "EDIT: Asynchronously is not the full truth". |
The more I read on this the more I'm horrified. I think I'll admit defeat and use a temporary file. |
I haven't been able to underestand anything further, so unfortunately the temporary file seems to be the only real workaround so far... |
Absent a better solution, would it be possible to go with the temporary file? |
Certainly. Just don't have the time at the moment. |
I think a diff --git a/src/cmdliner_manpage.ml b/src/cmdliner_manpage.ml
index 89435ae..941220a 100644
--- a/src/cmdliner_manpage.ml
+++ b/src/cmdliner_manpage.ml
@@ -490,7 +490,7 @@ let pp_to_pager print ppf v =
begin match tmp_file_for_pager () with
| None -> None
| Some tmp ->
- Some (strf "%s <%s >%s %s <%s" groffer f tmp pager tmp)
+ Some (strf "%s <%s >%s && %s <%s" groffer f tmp pager tmp)
end
| Some f ->
Some (strf "%s < %s | %s" groffer f pager) |
Ah yes of course. |
Signed-off-by: Etienne Millon <me@emillon.org>
Signed-off-by: Etienne Millon <me@emillon.org>
Pager man pages (what you get when you pass
--help
by default) are broken on Windows. The first page of the help page renders correctly, but all terminal input is frozen. The only solution to get unstuck seems to be to killgroff
andless
(in my setup, these are Cygwin binaries).Some more information:
The command line executed by
cmdliner
is of the formgroff -m man -K utf8 -T utf8 < help.groff | less -R
. It is executed usingSys.command
, iecmd.exe
on Windows:-P-c
to thegroff
command-line -> worksgroff
to a file$file
and then invokingless -R < $file
-> worksThe issue seems to be a bad interaction between
cmd.exe
pipeing, Cygwin binaries and color escape codes. A possible solution is to do as in the last point above and avoid the pipe by redirecting the output ofgroff
to an intermediate file, eg something along these lines (this patch fixed the problem in my system):The text was updated successfully, but these errors were encountered: