Skip to content

Commit

Permalink
Abort with error message if --dump argument invalid
Browse files Browse the repository at this point in the history
When --dump=FILE is passed a path that does not exist or is not
readable, it silently fails.
  • Loading branch information
adam12 committed Apr 16, 2024
1 parent 3ecf346 commit 0536b83
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rdoc/ri/driver.rb
Expand Up @@ -110,10 +110,6 @@ def self.process_args argv
options = default_options

opts = OptionParser.new do |opt|
opt.accept File do |file,|
File.readable?(file) and not File.directory?(file) and file
end

opt.program_name = File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
Expand Down Expand Up @@ -345,9 +341,17 @@ def self.process_args argv

opt.separator nil

opt.on("--dump=CACHE", File,
opt.on("--dump=CACHE",
"Dump data from an ri cache or data file.") do |value|
options[:dump_path] = value
unless File.readable?(value)
abort "#{value.inspect} is not readable"
end

if File.directory?(value)
abort "#{value.inspect} is a directory"
end

options[:dump_path] = File.new(value)
end
end

Expand Down

0 comments on commit 0536b83

Please sign in to comment.