Skip to content

Fix LESS environment variable setup in OptionParser#help_exit #84

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

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

kyanagi
Copy link
Contributor

@kyanagi kyanagi commented Jan 9, 2025

If the original value of LESS ends with an option starting with --, simply appending Fe would result in an invalid option string.

% LESS=--RAW-CONTROL-CHARS ruby -roptparse -e 'OptionParser.new.parse(ARGV)' -- --help
There is no RAW-CONTROL-CHARSFe option ("less --help" for help)
Press RETURN to continue

As far as I have tested, it seems that LESS can safely contain preceding spaces.

If the original value of LESS ends with an option starting with "--",
simply appending "Fe" would result in an invalid option string.
@fzakaria
Copy link

fzakaria commented Feb 9, 2025

I just hit this as I use the following in my Nix configuration:

  home.sessionVariables = {
    LESS = "--quit-if-one-screen --RAW-CONTROL-CHARS";
    EDITOR = "vim";
    # TODO(fmzakari): I might want this if I use home-manager on Linux non-NixOS
    # https://nixos.org/manual/nixpkgs/stable/#locales
    # LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
  };

Thanks for opening the issue; it saved me some hair pulling.

@nobu nobu merged commit 30571f9 into ruby:master Mar 10, 2025
@kyanagi kyanagi deleted the fix-help-less-env branch March 10, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants