GNU bug report logs - #50097
gzip: add "--keep" option to keep original files unchanged

Previous Next

Package: gzip;

Reported by: Krzysztof Żelechowski <giecrilj <at> stegny.2a.pl>

Date: Tue, 17 Aug 2021 17:45:01 UTC

Severity: wishlist

Full log


Message #38 received at 50097 <at> debbugs.gnu.org (full text, mbox):

From: Krzysztof Żelechowski <giecrilj <at> stegny.2a.pl>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Rodrigo Campos <rodrigo <at> sdfg.com.ar>, 50097 <at> debbugs.gnu.org,
 Antonio Diaz Diaz <antonio <at> gnu.org>
Subject: Re: bug#50097: gzip: add "--keep" option to keep original files
 unchanged
Date: Fri, 20 Aug 2021 16:52:50 +0200
Dnia piątek, 20 sierpnia 2021 16:42:54 CEST Paul Eggert pisze:
> On 8/20/21 5:20 AM, Krzysztof Żelechowski wrote:
> >> gzip -k b && gzip -cd b.gz >b
> >> 
> >> which would trash the hard-linked file as well.
> > 
> > That would replace the content of the file b with the content of the file
> > b. How bad can that be? ;-)
> 
> It could be a problem as-is if some other file reads 'a' in the middle
> of the process. And the problem would be more serious in other examples,
> such as:
> 
> echo hello >a
> ln a b
> gzip -k b && gzip -cd b.gz >>b
> 
> This would trash 'a' if gzip -k succeeded. (Same with 'ln -s'.)

The appending redirection operator has nothing to do with gzip.  It is a shell 
feature. If you need to protect dumb users from themselves, you need to design 
and implement { sh -o noclobberlinks; }.

> 
> >> > Of course one can use -f to go ahead and compress anyway.
> > 
> > That would silently replace an existing target, which is bad.
> 
> Sure. The only question here is what things "gzip -k" should be able to
> do, without the things being considered "bad".
> 
> Perhaps if you gave us the surrounding context; that might help explain
> why it would be useful to change the behavior of gzip -k on links. Bug
> report 50097 seems to start up in the middle of a conversation that I'm
> not privy to.

My normal usage of (hard) links is as follows:
Create a file page.txt. Link it to page.html.
Want to view? Open page.html.
Want to edit? Open page.txt.
Want to attach? gzip -k page.html … oops.

See ya,
Chris







This bug report was last modified 3 years and 78 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.