(Cc'ing Paul as suggested by Jim. Sorry if it wasn't useful.) gzip allows using "-" to indicate reading from stdin. However, if "-" is not the first name on the command line, it doesn't work:
$ echo test1 > test1 $ echo test2 > test2 $ echo test3 > test3 $ gzip test* $ cat test2.gz | gzip -dv test1.gz - test3.gz test1.gz: -33.3% -- replaced with test1 gzip: stdin: Bad file descriptor test1.gz is uncompressed, but test2.gz and test3.gz are not. The expected output would have been: test1.gz: -33.3% -- replaced with test1 test2 test3.gz: -33.3% -- replaced with test3 get_method calls functions that use the global variable ifd as the input file descriptor. The problem is that ifd isn't initialized when using "-" as the filename. It happens to work when "-" is the first filename, because ifd is zero (i.e. STDIN_FILENO) at program startup. The following minimal patch makes ifd initialization explicit when reading from stdin. Maybe a cleaner (but bigger) fix would be not to expect both the argument to get_method and the global ifd to have the same value. diff -ru gzip-1.3.12.orig/gzip.c gzip-1.3.12/gzip.c --- gzip-1.3.12.orig/gzip.c 2007-03-20 07:09:51.000000000 +0200 +++ gzip-1.3.12/gzip.c 2008-10-16 14:24:12.631442023 +0300 @@ -626,6 +626,7 @@ clear_bufs(); /* clear input and output buffers */ to_stdout = 1; part_nb = 0; + ifd = fileno(stdin); if (decompress) { method = get_method(ifd); -- Lasse Collin | IRC: Larhzu @ IRCnet & Freenode