Zlib::GzipReader doesn't work as expected



Hi,
given 2 files:
cat 5lines.txt
5 lines
5 lines
5 lines
5 lines
5 lines

cat more5lines.txt
More 5 lines
More 5 lines
More 5 lines
More 5 lines
More 5 lines

These files are "gzip"ed as follows:
gzip < 5lines.txt > foo.gz
gzip < more5lines.txt >> foo.gz

zcat foo.gz:
5 lines
5 lines
5 lines
5 lines
5 lines
More 5 lines
More 5 lines
More 5 lines
More 5 lines
More 5 lines

This ruby code only reads the first 5 lines:
#!/usr/bin/ruby
require "zlib"
filename = ARGV[0]

Zlib::GzipReader.open(filename) {|gz|
print gz.read
}

../test.rb foo.gz
5 lines
5 lines
5 lines
5 lines
5 lines

How do I force Zlib::GzipReader do read the whole file?

ruby versions: 1.8.7 and 1.9.0

Thanks and regards,
Thomas Wolf
.



Relevant Pages

  • Re: Useful use of cat
    ... Using cat to hand a pipe rather than a file to a non-largefile ... gzip's largefile limitation. ... There are three programs potentially involved here (cat, gzip, and the shell). ...
    (comp.unix.shell)
  • Re: Zlib::GzipReader doesnt work as expected
    ... cat more5lines.txt ... gzip > foo.gz ... You might get away with wrapping the GzipReader around an open IO object and wrapping another GzipReader when the first finishes. ...
    (comp.lang.ruby)
  • Re: Useful use of cat
    ... Using cat to hand a pipe rather than a file to a non-largefile ... % gzip <largefile> vs ... and the shell). ...
    (comp.unix.shell)
  • Re: strip leading X bytes from binary file.
    ... but he put in a UUOC. ... compressed with gzip. ... The 'cat' is needed if you have to send the output ... to a file because the decompressor can only work on files, ...
    (comp.unix.shell)
  • Re: load "/proc/self/fd/#{$stdin.fileno}"
    ... How can alternative OS independent Ruby code look like? ... $ cat bar.rb ... puts "in bar" ... eval data, nil, "your text here", 0 ...
    (comp.lang.ruby)