Subject: bug#62695: Gzip error

From: Jim Meyering <[email-masked]>
Date: Fri, 7 Apr 2023 08:04:48 -0700

On Thu, Apr 6, 2023 at 9:53 PM Petr Pisar <[email-masked]> wrote:
>
> V Thu, Apr 06, 2023 at 09:25:50AM +0000, Mary-Anne Freckleton via GNU gzip discussion and bug reports. napsal(a):
> > I am trying to gzip some files; however, I keep getting the error message
>
> The message is:
>
> $ gzip FILE_NAME
> gzip: FILE_NAME.gz: Operation not permitted
>
> The cause it that you don't have a permission for writing into the directory
> where gzip tries to create the FILE_NAME.gz archive.
>
> Linux has a great tool for tracing what system calls programs do and that
> shows it:
>
> $ strace -- gzip sauer_client
> execve("/bin/gzip", ["gzip", "sauer_client"], 0x7ffe4c58d4e0 /* 75 vars */) = 0
> [...]
> openat(3, "sauer_client.gz", O_WRONLY|O_CREAT|O_EXCL, 0600) = -1 EACCES (Operace zamítnuta)
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> write(2, "gzip: ", 6gzip: )                   = 6
> write(2, "sauer_client.gz: Permission deni"..., 35sauer_client.gz: Permission denied
> ) = 35
>
> You can use "ls -ld ." command to see the permission bits of your current
> working directory.
>
> > displayed below in the screenshot.
>
> Next time, please, instead of a screenshot which consumes 10 MB, simply copy
> and paste the text from your terminal.
>
> > We have all of the text files in a folder
> > and are not sure what we’re doing wrong (as we’ve never seen this issue
> > before).
>
> I agree the error message is not the best. Gzip might change the message to
> express what operation (opening a file for writing) failed.

Thanks for the suggestion.
I've just pushed the attached to address that.

This highlights that gzip has many additional sub-par diagnostics like
that. And I note that it uses "fprintf(stderr", while the vast
majority of GNU programs use "error(", which is better. Also gzip has
no internationalization support. But fixing all of this feels like
it'd be too much like applying lipstick to a pig.