GNU bug report logs - #20002
sed: tmp file left when there are errors and -i is used

Previous Next

Package: sed;

Reported by: David Jones <drj <at> pobox.com>

Date: Wed, 4 Mar 2015 17:56:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20002 in the body.
You can then email your comments to 20002 AT debbugs.gnu.org in the normal way.

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#20002; Package sed. (Wed, 04 Mar 2015 17:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Jones <drj <at> pobox.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Wed, 04 Mar 2015 17:56:02 GMT) Full text and rfc822 format available.

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

From: David Jones <drj <at> pobox.com>
To: bug-sed <at> gnu.org
Subject: sed: tmp file left when there are errors and -i is used
Date: Wed, 4 Mar 2015 17:32:37 +0000
sed -i sometimes leave its temporary files around:

Here's some terminal output:

drj$ ls
foo
drj$ sed -i 's//b/' foo
sed: -e expression #1, char 0: no previous regular expression
drj$ ls
foo  sedaelyL4

Note that the sedaelyL4 file is obviously a temp file left by sed. sed
had an error because of the bad sed program. But sed should clean up
after itself.

Cheers,
 drj



The output of sed --version is:

$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed <at> gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 10 May 2015 13:46:03 GMT) Full text and rfc822 format available.

Notification sent to David Jones <drj <at> pobox.com>:
bug acknowledged by developer. (Sun, 10 May 2015 13:46:04 GMT) Full text and rfc822 format available.

Message #10 received at 20002-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: David Jones <drj <at> pobox.com>, 20002-done <at> debbugs.gnu.org
Subject: Re: sed: tmp file left when there are errors and -i is used
Date: Sun, 10 May 2015 06:45:21 -0700
[Message part 1 (text/plain, inline)]
[David Jones reported this in http://bugs.gnu.org/20002]
Thank you for the report.
That was indeed a bug.
I have attached the patch I expect to push:

[PATCH] sed -i: don't leave behind a temporary sedXXXXXX file

For example, running a command like "sed -i s//b/ F" would fail
to remove a temporary file named sedXXXXXX (for random XXXXXX)
in the directory alongside F.
* sed/sed.c (G_file_to_unlink): New global.
(register_cleanup_file, cancel_cleanup, cleanup): New functions.
(main): Call atexit.
* sed/execute.c (open_next_file): Register for unlink.
(closedown): Call cancel_cleanup right after the rename.
* sed/sed.h: Declare two of the new functions.
* NEWS (Bug fixes): Mention it.
* testsuite/temp-file-cleanup.sh: New file.  Test for this.
* testsuite/Makefile.am (T): Add it.
Reported by David Jones in http://bugs.gnu.org/20002.
[0001-sed-i-don-t-leave-behind-a-temporary-sedXXXXXX-file.patch (application/octet-stream, attachment)]

Information forwarded to bug-sed <at> gnu.org:
bug#20002; Package sed. (Sun, 10 May 2015 16:37:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: 20002 <at> debbugs.gnu.org, Jim Meyering <jim <at> meyering.net>, drj <at> pobox.com
Subject: Re: bug#20002: sed: tmp file left when there are errors and -i is used
Date: Sun, 10 May 2015 09:36:27 -0700
[Message part 1 (text/plain, inline)]
On Sun, May 10, 2015 at 6:45 AM, Jim Meyering <jim <at> meyering.net> wrote:
> [David Jones reported this in http://bugs.gnu.org/20002]
> Thank you for the report.
> That was indeed a bug.
> I have attached the patch I expect to push:
>
> [PATCH] sed -i: don't leave behind a temporary sedXXXXXX file
>
> For example, running a command like "sed -i s//b/ F" would fail
> to remove a temporary file named sedXXXXXX (for random XXXXXX)
> in the directory alongside F.
> * sed/sed.c (G_file_to_unlink): New global.
> (register_cleanup_file, cancel_cleanup, cleanup): New functions.
> (main): Call atexit.
> * sed/execute.c (open_next_file): Register for unlink.
> (closedown): Call cancel_cleanup right after the rename.
> * sed/sed.h: Declare two of the new functions.
> * NEWS (Bug fixes): Mention it.
> * testsuite/temp-file-cleanup.sh: New file.  Test for this.
> * testsuite/Makefile.am (T): Add it.
> Reported by David Jones in http://bugs.gnu.org/20002.

This required the following fix-up patch:
[0001-build-avoid-warning-about-implicit-declaration-of-un.patch (application/octet-stream, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Jun 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 317 days ago.

Previous Next


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