--- Begin Message ---
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: <address@hidden>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
--- End Message ---
--- Begin Message ---
Subject: |
Re: sed: tmp file left when there are errors and -i is used |
Date: |
Sun, 10 May 2015 06:45:21 -0700 |
[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
Description: Binary data
--- End Message ---