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 option --use-color not supported in all regions #2335

Open
p-phillips opened this issue Feb 25, 2025 · 4 comments
Open

PAGER option --use-color not supported in all regions #2335

p-phillips opened this issue Feb 25, 2025 · 4 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike.

Comments

@p-phillips
Copy link

I've just had to start using hledger on a different machine than usual (Ubuntu 20.04) due to the death of my Ubuntu 24.04 laptop, and I noticed that commands I'm running from a Makefile were halting due to a problem with the PAGER command line options.

Specifically I was getting this error message:

There is no use-color option ("less --help" for help)

It took me a while to track this down (grepping all of my zsh config files etc) but it turns out it's because of the default pager options that hledger turns on - as the man page says:

(At the time of writing: --chop-long-lines --hilite-unread --ignore-case --mouse --no-init --quit-at-eof --quit-if-one-screen --RAW-CONTROL-CHARS --shift=8 --squeeze-blank-lines --use-backslash --use-color ). If these don't work well, you can set your preferred options in the HLEDGER_LESS variable, which will be used instead.

It appears that less is region specific - i.e., I'm in Wales in the UK, and we spell 'colour' (not 'color') so less accepts '--use-colour' but not '--use-color'!!!! (I'm as surprised about this as you probably are).

I've fixed it on my machine by setting HLEDGER_LESS to include '--use-colour':

export HLEDGER_LESS="--chop-long-lines --hilite-unread --ignore-case --mouse --no-init --quit-at-eof --quit-if-one-screen --RAW-CONTROL-CHARS --shift=8 --squeeze-blank-lines --use-backslash --use-colour"

However there must be other non-USA folks bitten by the same issue. Is there a simple fix for this ? Can the code be amended to set a region-specific flag and use colour instead of color ? Or is there another way around this?

Pete

PS: The switch of machines meant I was sending the output to a screen - I usually send them through a pipe to a printer and in that case the pager doesn't kick in of course - so I don't think it's the different versions of OS that triggers this.

@simonmichael simonmichael added A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. labels Feb 26, 2025
@simonmichael
Copy link
Owner

simonmichael commented Feb 26, 2025

Thanks for the investigation and report. Yes I'm extremely surprised to hear that. Are you sure you're not using some variant or older version of the official less ? My less --version is

$ less --version
less 668 (PCRE2 regular expressions)
Copyright (C) 1984-2024  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

from /opt/homebrew/bin/less.

@p-phillips
Copy link
Author

p-phillips commented Feb 26, 2025 via email

@p-phillips
Copy link
Author

p-phillips commented Feb 26, 2025 via email

@simonmichael
Copy link
Owner

simonmichael commented Feb 28, 2025

Quite a mystery. Could a shell function or alias be getting in the way ?

I did

$ type -a less
less is /opt/homebrew/bin/less
less is /usr/bin/less
$ /opt/homebrew/bin/less --help | grep 'use-c'
                --use-color
$ strings /opt/homebrew/bin/less | grep 'use-c'
Set --use-color before changing colors
use-color
                --use-color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike.
Projects
None yet
Development

No branches or pull requests

2 participants