You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something that might be more portable is piping into groff:
$ cabal man --raw | groff -Tutf8 -i | less
(That looks horrible. But even the HTML rendering is horrible.)
However, the output of cabal man is not well-formatted, it seems:
$ cabal man --raw | groff -Tutf8 -i > /dev/null 2> man-errors.txt
$ cat man-errors.txt
<standard input>:3825: warning: macro `new-repl'' not defined (probably missing space after `ne')
<standard input>:20376: warning: macro `new-build',' not defined (probably missing space after `ne')
<standard input>:20381: warning: macro `new-build' not defined (probably missing space after `ne')
Quick fix is to drop the piping into man part and make --raw the default.
Then folks can choose their OS-specific rendering of their taste.
Is there any way to make man read a page from stdin (or at least from a file) on macos? does cabal man --raw | man /dev/stdin work? what about cabal man --raw > temporary_file && man temporary_file? I guess no due to the groff error?
We have to keep in mind that nroff/groff could be absent too! For example in NixOS:
$ cabal man --raw | nroff -man /dev/stdin
The program 'nroff' is not in your PATH. You can make it available in an
ephemeral shell by typing:
nix-shell -p groff
I think this is a lot of hoops to jump through for a rarely used command that doesn't seem particularly important for most purposes? I'm in favor of doing a basic fix to it, but unless we already have infrastructure in place to lookup a pager etc, probably overkill.
Reacted by Mikolaj Konarski and Francesco Gazzetta
Oh for sure, I just meant that the fix shouldn't be at the expense of other users, like in linux, where man is ubiquitous and respects $PAGER, but groff isn't as much.
I wasn't actually proposing to check for $PAGER, just to case on the platform, which would be strictly an improvement for all users. The pager issue was an argument for keeping man where possible.
edit: well ok, nroff is actually a dependency of man, it's just that NixOS doesn't expose dependencies by default, which isn't what the majority does. So I guess this affects less platforms than I thought, and only the $PAGER regression remains, which is minor compared to making the command work on all platforms
The output of cabal man --raw is producing the following problems when piped into nroff -man:
The sequence 'ne, if placed a the beginning of a line, seems to invoke a macro:
cabal.man:3825: warning: macro `new-repl'' not defined (probably missing space after `ne')
This happens when quotes like 'new-repl' etc. end up at the beginning of the line by chance.
A fix is to not have a line break before 'ne, but this is maybe not so obvious how to realize this.
Problems with .R:
`R' is a string (producing the registered sign), not a macro.
Activity
andreasabel commentedon Oct 7, 2021
Something that might be more portable is piping into
groff:(That looks horrible. But even the HTML rendering is horrible.)
However, the output of
cabal manis not well-formatted, it seems:Quick fix is to drop the piping into
manpart and make--rawthe default.Then folks can choose their OS-specific rendering of their taste.
fgaz commentedon Oct 7, 2021
Is there any way to make
manread a page from stdin (or at least from a file) on macos? doescabal man --raw | man /dev/stdinwork? what aboutcabal man --raw > temporary_file && man temporary_file? I guess no due to the groff error?gbaz commentedon Oct 7, 2021
What about using nroff instead of groff as in https://unix.stackexchange.com/a/313110 ?
andreasabel commentedon Oct 7, 2021
Here is man's man page for BSD: https://www.freebsd.org/cgi/man.cgi?query=man
@fgaz wrote:
Thanks indeed, this works, yet without formatting.
However, this is of limited use because:
cabal manproduces a 50kloc text! Not sure that this meets the intuitive expectations of a man page.It seems like every option is repeated for each command. The text is highly redundant:
So, it is inflated by a factor of >30.
What is actually the purpose of
cabal man? Dump the whole help text rather than exploring it via the--helpflag?Is it used to automatically produce man-pages for some distro?
@gbaz wrote:
Thanks, this actually produces nice formatting.
It still suffers from the redundancy problem, though.
Fix haskell#7714: use `nroff -man | less` as backend for `cabal man`
andreasabel commentedon Oct 8, 2021
See #7714: I am trying to implement a pipe in Haskell to the effect of
but for some reason it does not do what I would expect. Help wanted!
fgaz commentedon Oct 8, 2021
We have to keep in mind that nroff/groff could be absent too! For example in NixOS:
Should the command depend on the platform?
Furthermore,
lessmay not be the user's$PAGERgbaz commentedon Oct 8, 2021
I think this is a lot of hoops to jump through for a rarely used command that doesn't seem particularly important for most purposes? I'm in favor of doing a basic fix to it, but unless we already have infrastructure in place to lookup a pager etc, probably overkill.
fgaz commentedon Oct 9, 2021
Oh for sure, I just meant that the fix shouldn't be at the expense of other users, like in linux, where
manis ubiquitous and respects$PAGER, butgroffisn't as much.I wasn't actually proposing to check for
$PAGER, just to case on the platform, which would be strictly an improvement for all users. The pager issue was an argument for keepingmanwhere possible.edit: well ok, nroff is actually a dependency of man, it's just that NixOS doesn't expose dependencies by default, which isn't what the majority does. So I guess this affects less platforms than I thought, and only the $PAGER regression remains, which is minor compared to making the command work on all platforms
andreasabel commentedon Oct 12, 2021
The output of
cabal man --rawis producing the following problems when piped intonroff -man:'ne, if placed a the beginning of a line, seems to invoke a macro:'new-repl'etc. end up at the beginning of the line by chance.A fix is to not have a line break before
'ne, but this is maybe not so obvious how to realize this..R:man nodeproduces warnings on macOS nodejs/node#18434 (comment) the prefix.Ris superfluous ("pretty silly") and can be deleted. This removes the warnings.2 remaining items
Re haskell#7714: fix Linux CI by installing groff-base to get nroff
Re haskell#7714: don't test nroff-ability of `cabal man --raw` under …
hasufell commentedon Jan 19, 2022
apparently, this also happens on BSD
fgaz commentedon Jan 19, 2022
@hasufell feel free to review #7726 ;)
Fix haskell#7714: use `nroff -man | less` as backend for `cabal man`
Re haskell#7714: export ignoreSigPipe from D.Simple.Utils for `cabal …
Re haskell#7714: fix Linux CI by installing groff-base to get nroff
Re haskell#7714: don't test nroff-ability of `cabal man --raw` under …
Merge pull request #7726 from andreasabel/issue7714-manpage
Changelog for #7714 / #7726: cabal man
Changelog for #7714 / #7726: cabal man (#7935)
Changelog for haskell#7714 / haskell#7726: cabal man (haskell#7935)