Skip to content

Commit 30571f9

Browse files
kyanaginobu
authored andcommitted
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.
1 parent 262cf6f commit 30571f9

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)