From 3cd3f766799eb1e591356acde3ab863e3bb3566a Mon Sep 17 00:00:00 2001 From: Kouhei Yanagita Date: Thu, 9 Jan 2025 11:00:54 +0900 Subject: [PATCH] [ruby/optparse] Fix LESS environment variable setup in OptionParser#help_exit If the original value of LESS ends with an option starting with "--", simply appending "Fe" would result in an invalid option string. https://github.com/ruby/optparse/commit/30571f91d3 --- lib/optparse.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/optparse.rb b/lib/optparse.rb index f849a9cc97..f32edc5df3 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1058,7 +1058,7 @@ XXX def help_exit if $stdout.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?}) less = ENV["LESS"] - args = [{"LESS" => "#{!less || less.empty? ? '-' : less}Fe"}, pager, "w"] + args = [{"LESS" => "#{less} -Fe"}, pager, "w"] print = proc do |f| f.puts help rescue Errno::EPIPE