summaryrefslogtreecommitdiff
path: root/lib/optparse.rb
diff options
context:
space:
mode:
authorKouhei Yanagita <[email protected]>2025-01-09 11:00:54 +0900
committergit <[email protected]>2025-03-10 10:21:29 +0000
commit3cd3f766799eb1e591356acde3ab863e3bb3566a (patch)
tree99fab72e75963cc5a71d698fdf5be01326d186c7 /lib/optparse.rb
parentf4c16c57aad9138f236f4fa966893b21d5a64cbf (diff)
[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
Diffstat (limited to 'lib/optparse.rb')
-rw-r--r--lib/optparse.rb2
1 files changed, 1 insertions, 1 deletions
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