Skip to content
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 broken when setting PAGER=less #167

Closed
nojb opened this issue Nov 23, 2022 · 5 comments
Closed

Pager help pages broken when setting PAGER=less #167

nojb opened this issue Nov 23, 2022 · 5 comments
Labels

Comments

@nojb
Copy link

nojb commented Nov 23, 2022

This is a report that came from the Dune team. Recently Dune upgraded its vendored copy of cmdliner to 1.1.1, and users who set PAGER=less (a usual setting) find that their help pages are broken (because color codes are not interpreted).

However, I remembered that colors and paging work fine in git even when setting PAGER=less. It turns out that what they do is to pass the -R flag by setting the LESS environment variable, which has the virtue of affecting not only the less pager directly invoked by cmdliner but also when it is invoked through the PAGER variable.

git/git@25fc178

I'm not sure how to set the environment variable without using Unix, though...

@dbuenzli
Copy link
Owner

I have to admit that with the age my patience with dealing with broken and undesigned systems is reaching zero.

If someone is willing to sift through all these ruins, idiosyncrasies and duct tape to provide me with a clear spec of what needs to be done so that everything works correctly I'm happy to implement it. But I have neither the energy nor the envy to research it.

I'm not sure how to set the environment variable without using Unix, though...

Well system(3) is supposed to interpret the given expression via a POSIX shell so I guess we could use VAR=value cmd but of course this would have to survive all the insane quotation layers and the likely various broken implementations of system.

@dbuenzli
Copy link
Owner

I guess we could use VAR=value cmd

So 1de3611 does that, though I'm pretty sure I'm getting myself involved in more unpleasantness.

Taking from my (sanely implemented via unix) pager abstraction here
I use FRX rather than FRSX. The difference seems to be related to wrapping, horizontal scrolling is rather unconvenient but if people have a reason to add that S I could be convinced to add it.

@nojb
Copy link
Author

nojb commented Jan 18, 2023

I guess we could use VAR=value cmd

So 1de3611 does that, though I'm pretty sure I'm getting myself involved in more unpleasantness.

Good guess :)

system(3) passes the string to cmd.exe on Windows which is not POSIX. In particular I don't think the syntax VAR=xxx prog args is understood by it. Some googling indicates that the right syntax for cmd.exe would be something like set LESS=FRX && less <args>. It seems to work for the less invocation in #166 (comment).

@dbuenzli
Copy link
Owner

Thanks! f239981 does what you suggest.

@nojb
Copy link
Author

nojb commented Feb 20, 2023

I think this can be closed. I haven't tested again after the latest fix (I'm waiting for #166 before testing again), but I believe it should have solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants