Skip to content

Commit 3cd3f76

Browse files
kyanagimatzbot
authored andcommitted
[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. ruby/optparse@30571f91d3
1 parent f4c16c5 commit 3cd3f76

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/optparse.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ def compsys(to, name = File.basename($0)) # :nodoc:
10581058
def help_exit
10591059
if $stdout.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?})
10601060
less = ENV["LESS"]
1061-
args = [{"LESS" => "#{!less || less.empty? ? '-' : less}Fe"}, pager, "w"]
1061+
args = [{"LESS" => "#{less} -Fe"}, pager, "w"]
10621062
print = proc do |f|
10631063
f.puts help
10641064
rescue Errno::EPIPE

0 commit comments

Comments
 (0)