-
Notifications
You must be signed in to change notification settings - Fork 719
Fix #7714: use nroff -man | less
as backend for cabal man
#7726
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
Conversation
Weirdly enough, it could be because the generated text is too long (800kB). If I truncate it to 192kB (this is a precise hard bound, 1 char more is too much(!)), it works... |
i wouldn't construct pipe, but rather read in the result of https://hackage.haskell.org/package/Cabal-3.6.2.0/docs/Distribution-Simple-Utils.html#v:rawSystemStdInOut as a bonus, no low-level |
if you really want a pipe (which i wouldn't recommend), you need to make one https://hackage.haskell.org/package/process-1.6.13.2/docs/System-Process.html#g:7. |
@phadej wrote:
The documentation suggests that a pipe is created when the |
Thanks, I'll try that! |
Yes a pipe is created, for example for standard output: Library gives the writing end to the spawned process and gives the reading end to you. A pipe (= two FDs) is created, but you get only one end of it. |
Which I hand as stdin to the second process. I thought that is exactly what a pipe is. |
Indeed. Weird. (also |
3005b13
to
fe8bce7
Compare
Got the piping to work by not piping. New commit message:Fix #7714: use Directly piping into
Also fixed output of
Added to Remaining problem:Unfortunately, after quitting
Not sure how to fix this (my attempts failed). |
Process.Inherit -- err | ||
|
||
hPutStr inLess formatted | ||
hClose inLess |
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.
The presence of hClose
here does not seem to make a difference.
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.
Just brainstorming: hFlush
before close?
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.
It would be best to add a new helper to D.Simple.Utils
. I'm somewhat surprised there isn't such "takes input, inherits output" variant already. EDIT: and do stdin writing as elsewhere.
You have to ignore it. Grep for |
Also an error in tests:
I think we should fallback to |
For the record, e.g. |
@phadej: Thanks for the review, I am working on it.
The problem that I am trying to fix here is that BSD-
So it is not the problem of |
Yes, my comment was just answering my own curiosity, i.e. how |
Update:
Not addressed (yet):
Didn't understand this comment:
|
@@ -79,6 +79,10 @@ jobs: | |||
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan | |||
rm -f cabal-plan.xz | |||
chmod a+x $HOME/.cabal/bin/cabal-plan | |||
- name: apt-get update | |||
run: apt-get update | |||
- name: Install `nroff` for `cabal man` |
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.
that is so weird that buildpack-deps
base image doesn't have man-db
installed. Though it kind of make sense, it still is weird.
refers to the wish that we rather add a new helper to EDIT: I should had done that myself, my only excuse is that no-one was reviewing PRs back then and preventing me from cutting corners. |
The existing cabal/Cabal/src/Distribution/Simple/Utils.hs Lines 884 to 892 in 69dbf54
does not lend itself easily to stdin/stdout inheritance; this may explain why such helpers do not exist yet.
I am not well versed with processes and don't understand the code of CI passes now, but I would appreciate some manual inspection of the result of |
Btw, @phadej, I got enlightened why my original code did not work: haskell/process#218. I fell into a boobie trap with |
Can this PR be merged now? I may not be perfect, but it improves on the status quo, I think. |
Any further comments, anybody? @hasufell, would you like to review? |
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.
@andreasabel I added some fixes here: andreasabel#1
Directly piping into `man -l -` does not work as BSD-`man` does not understand option `-l`. More standardized are the building blocks `nroff` and `less`. `cabal man` now should behave as pipeline ``` cabal man --raw | nroff -man /dev/stdin | less ``` Also fixed output of `cabal man --raw` so that it does not produce warnings. - `.R` removed. Was warning: ``` `R' is a string (producing the registered sign), not a macro. ``` - No quoted 'new-FOO' should appear at beginning of line. Was warning: ``` warning: macro `new-FOO'' not defined (probably missing space after `ne') ``` Added to `cabal-testsuite/PackageTests/Man/cabal.test.hs` a check that the `stderr` output of `nroff -man /dev/stdin` is empty (no warnings). Remaining problem: Unfortunately, after quitting `less` with `q` the following error is displayed: ``` fd:NNN: commitBuffer: resource vanished (Broken pipe) ``` Not sure how to fix this (my attempts failed).
…Windows Windows does not have `nroff` (neither has it `man`) and `cabal man` fails there usually for lack of these backends.
Also: Fix color formatting when PAGER is 'less'
315fab2
to
47a859f
Compare
Mergiofy was waiting on the "Artifacts" workflows, but these seem gone. So I deleted them from the required statuses list for master in Settings/Branches. Hope that was intended. |
Yes, it was, thank you! |
This will need a changelog entry |
Fix #7714: use
nroff -man /dev/stdin | less
as backend forcabal man
WIP: This does not work yet, I need some help with constructing the pipe correctly in Haskell.
I seem to follow the example at
https://stackoverflow.com/questions/41030168/haskell-using-the-handle-created-from-createprocess-and-createpipe-to-pipe-int
which works for me, but my patch does not seem to invoke
less
correctly.Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!