Hi,

There is a problem with gzip-1.7 when piping output with the 'list' option. Specifically, both
    gzip -l file.gz > output
and
    gzip -l file.gz | grep -q pattern ...

produce

gzip: write error: Bad file descriptor

This issue is due to the following code (I assume to the close()):

gzip-1.7/gzip.c:670

 670     if (to_stdout
 671         && ((synchronous
 672              && (fdatasync (STDOUT_FILENO) != 0 && errno != EINVAL))
 673             || close (STDOUT_FILENO) != 0)
 674         && errno != EBADF)
 675       write_error ();

In the cases above, to_stdout=1, and synchronous=0.

The issue appears to be 'list' specific, eg,

    gzip -dc file.gz | grep -q pattern ...

looks ok.

Perhaps line 670 should be:

670     if (!list && to_stdout

or, not set to_stdout in the list case ? Not sure..

thanks,
John

Thanks,
John




Reply via email to