def options_check_files(cast)
if cast[:type] == 'files!' and @options.has_key? cast[:long]
@options[cast[:long]].each do |path|
+ next if path == "-"
raise ArgumentError, "File not readable: '#{path}'" unless File.readable? path
end
end
# specified in options[:stream_out] or options[:data_out].
def self.open(options, mode, stdio)
if mode == "r"
- $stdin.tty? ? read(options[:stream_in]) : stdio
+ if options[:data_in].first == "-"
+ self.nread(["-"])
+ else
+ $stdin.tty? ? read(options[:stream_in]) : stdio
+ end
elsif mode == "w"
options[:stream_out] ? self.write(options[:stream_out], options[:compress]) : stdio
else
# Class method allowing open to be used on (zipped) files.
# See File.open.
def self.open(*args)
- if File.pipe? *args.first
+ tyt = *args
+ if tyt.first == "-"
+ ios = self.new(STDIN)
+ elsif File.pipe? *args.first
ios = self.new(File.open(*args))
else
ios = self.zopen(*args)