GNU bug report logs - #40325
make backup files for "-i" option invisible

Previous Next

Package: sed;

Reported by: nokangaroo <aon.913677709 <at> aon.at>

Date: Mon, 30 Mar 2020 15:42:01 UTC

Severity: normal

To reply to this bug, email your comments to 40325 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#40325; Package sed. (Mon, 30 Mar 2020 15:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to nokangaroo <aon.913677709 <at> aon.at>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Mon, 30 Mar 2020 15:42:02 GMT) Full text and rfc822 format available.

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

From: nokangaroo <aon.913677709 <at> aon.at>
To: bug-sed <at> gnu.org
Subject: make backup files for "-i" option invisible
Date: Sat, 28 Mar 2020 17:00:12 +0100
The visible backup files create problems with file managers, e. g. they show up
in MATE, and I have to reload the folder to make them disappear. The following
patch creates invisible files:

--- sed/execute.c	2020-01-01 20:38:19.000000000 +0100
+++ sed/execute.c	2020-03-26 12:17:30.209662815 +0100
@@ -614,7 +614,7 @@
             }
         }
 
-      output_file.fp = ck_mkstemp (&input->out_file_name, tmpdir, "sed",
+      output_file.fp = ck_mkstemp (&input->out_file_name, tmpdir, ".sed",
                                    write_mode);
       register_cleanup_file (input->out_file_name);
       output_file.missing_newline = false;


This works because ck_mkstemp tests for strlen.
BTW why not use /tmp instead of '.'?

-- 
nokangaroo <aon.913677709 <at> aon.at>




Information forwarded to bug-sed <at> gnu.org:
bug#40325; Package sed. (Tue, 31 Mar 2020 05:21:02 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: nokangaroo <aon.913677709 <at> aon.at>, 40325 <at> debbugs.gnu.org
Subject: Re: bug#40325: make backup files for "-i" option invisible
Date: Mon, 30 Mar 2020 23:20:48 -0600
[Message part 1 (text/plain, inline)]
Hello,

On 2020-03-28 10:00 a.m., nokangaroo wrote:
> The visible backup files create problems with file managers, e. g. they show up
> in MATE, and I have to reload the folder to make them disappear. The following
> patch creates invisible files:

Nice idea, and doesn't seem to cause any regressions.
If there are no objects (Jim?), I'll push this soon in your name.
The patch is small enough that copyright assignment is not necessary.

> BTW why not use /tmp instead of '.'?

When using "-i/--in-place", the new content is first written
to the temporary file, and then a rename(2) sys-call is used to replace
the input file with the new file.

When the two files are in the same directory,
such rename(2) sys-call is atomic and quick.

On many systems the "/tmp" directory is mounted
on a different file system (or in memory),
and we'd have to use a non-atomic and slower "copy+delete" instead of
a rename(2).

regards,
 - assaf




[0001-sed-make-backup-files-for-i-option-invisible.patch (text/x-patch, attachment)]

Information forwarded to bug-sed <at> gnu.org:
bug#40325; Package sed. (Fri, 03 Apr 2020 23:01:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: nokangaroo <aon.913677709 <at> aon.at>, 40325 <at> debbugs.gnu.org
Subject: Re: bug#40325: make backup files for "-i" option invisible
Date: Fri, 3 Apr 2020 16:00:24 -0700
On Mon, Mar 30, 2020 at 10:21 PM Assaf Gordon <assafgordon <at> gmail.com> wrote:
> Hello,
>
> On 2020-03-28 10:00 a.m., nokangaroo wrote:
> > The visible backup files create problems with file managers, e. g. they show up
> > in MATE, and I have to reload the folder to make them disappear. The following
> > patch creates invisible files:
>
> Nice idea, and doesn't seem to cause any regressions.
> If there are no objects (Jim?), I'll push this soon in your name.
> The patch is small enough that copyright assignment is not necessary.
>
> > BTW why not use /tmp instead of '.'?
>
> When using "-i/--in-place", the new content is first written
> to the temporary file, and then a rename(2) sys-call is used to replace
> the input file with the new file.
>
> When the two files are in the same directory,
> such rename(2) sys-call is atomic and quick.
>
> On many systems the "/tmp" directory is mounted
> on a different file system (or in memory),
> and we'd have to use a non-atomic and slower "copy+delete" instead of
> a rename(2).

Thank you both!
Perhaps s/invisible/hidden/ in the commit log. Also, Assaf, would you
please add a NEWS entry, since this is a user-visible change?

Thanks,
Jim




This bug report was last modified 5 years and 73 days ago.

Previous Next


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