less-fork icon indicating copy to clipboard operation
less-fork copied to clipboard

Get variables LESS_TERMCAP_* from lesskey file

Open olibre opened this issue 8 years ago • 5 comments

The command less skips the variables LESS_TERMCAP_* defined in the lesskey file (e.g. ~/.less).

This is because, the function main() retrieves the variables LESS_TERMCAP_* before loading of the lesskey file. I propose to just invert two lines.

I explain that in details on this site: https://unix.stackexchange.com/a/377221/13999

This is the current source code at line 110 in main.c

/*
 * Process command line arguments and LESS environment arguments.
 * Command line arguments override environment arguments.
 */
is_tty = isatty(1);
get_term();
init_cmds();
init_charset();
init_line();

This is the fix I have validated on my computer:

/*
 * Process command line arguments and LESS environment arguments.
 * Command line arguments override environment arguments.
 */
is_tty = isatty(1);
init_cmds();         /* Load lesskey file before */
get_term();          /* getting variables LESS_TERMCAP_* */
init_charset();
init_line();

I have just inverted two lines: get_term(); and init_cmds();

Questions:

  • Do you want a pull request ?
  • Do you want to follow the bug-fix from upstream project ?

For information I have sent the same bug report a fix proposal to the less mainteners.

olibre avatar Jul 08 '17 22:07 olibre

Inverting the two function calls get_term() and init_cmds() has some major regression issues.

The fix is in discussion with @rivy and official maintainer Mark Nudelman (and original author since 34 years).

A good fix should be implemented soon...

olibre avatar Jul 18 '17 05:07 olibre

Let me know once you've got a good solution to this. Then I'm happy to review a PR.

gdamore avatar Aug 03 '17 17:08 gdamore

Hi Garrett. I have successfully tested the beta version as proposed by Mark Nudelman (that version fixes this issue). You will have a new release on http://greenwoodsoftware.com/less/ in the coming months... Mark Nudelman has clean a bit the source code removing, for example, the keyword register as you did. Thank you for your work. Cheers

olibre avatar Aug 12 '17 09:08 olibre

Thanks. Can I close this PR pending a new one with changes?

gdamore avatar Nov 10 '17 20:11 gdamore

Yes you may close this Issue. However I do not have time/motivation to prepare a Pull Request to fix the issue.

olibre avatar Nov 14 '17 14:11 olibre