Skip to content

Commit

Permalink
Fixed bug when arguments include stdin: lolcat file1 - file2 > file3
Browse files Browse the repository at this point in the history
  • Loading branch information
WildUtah committed Feb 3, 2017
1 parent dfc6864 commit 512197a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/lolcat/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,21 @@ def self.cat!
begin
files = ARGV.empty? ? [:stdin] : ARGV[0..-1]
files.each do |file|
fd = ARGF if file == '-' or file == :stdin
fd = $stdin if file == '-' or file == :stdin
begin
fd = File.open file unless fd == ARGF
fd = File.open(file, "r") unless fd == $stdin

if $stdout.tty? or opts[:force]
Lol.cat fd, opts
else
until fd.eof? do
$stdout.write(fd.read(8192))
if fd.tty?
fd.each do |line|
$stdout.write(line)
end
else
until fd.eof? do
$stdout.write(fd.read(8192))
end
end
end
rescue Errno::ENOENT
Expand Down
2 changes: 1 addition & 1 deletion lib/lolcat/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Lolcat
VERSION = "42.24.0"
VERSION = "42.24.1"
end

0 comments on commit 512197a

Please sign in to comment.