The following "patch" fixed the problem. It does so by looking at the target. 
If it is an symlink the tmp file will be copied
to the target of the symlink. Patch also included as attachment.

elektron.m% diff -ur sed-4.1.5/lib/utils.c sed-4.1.5-modified/lib/utils.c
--- sed-4.1.5/lib/utils.c       2005-06-21 16:09:40.000000000 +0200
+++ sed-4.1.5-modified/lib/utils.c      2009-04-27 11:04:38.003830559 +0200
@@ -321,7 +321,19 @@
   const char *from, *to;
   const char *unlink_if_fail;
 {
-  int rd = rename (from, to);
+  /* if to is a symlink, shouldn't we move the the link name instead? */
+  char *buf[255];
+  int rd;
+  ssize_t  sym;
+  if ((sym = readlink(to, buf, 254)) != -1) 
+    {
+      buf[sym] = '\0';
+      rd = rename (from, buf);
+    }
+  else 
+   {
+      rd = rename (from, to);
+   }
   if (rd != -1)
     return;
 


** Attachment added: "Fix symlink behavoir in sed"
   http://launchpadlibrarian.net/26021447/patch

-- 
sed -i destroys symlink
https://bugs.launchpad.net/bugs/367211
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to