Re: sed 4.2.2 does not operate on streams when --follow-symlinks is passed

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Il 09/01/2013 06:50, Luke T. Shumaker ha scritto:
> sed 4.2.2 introduced the change from 4.2.1 that the
> `--follow-symlinks` option breaks sed's ability to operate on
> streams.
> 
> This option is clearly non-applicable in the situation of editing a
> stream, but should not break in that situation.

This patch should fix it:

diff --git a/sed/execute.c b/sed/execute.c
index cb84192..bce6b6c 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -580,6 +580,7 @@ open_next_file(name, input)
 {
   buffer.length = 0;
 
+  input->in_file_name = name;
   if (name[0] == '-' && name[1] == '\0' && !in_place_extension)
     {
       clearerr(stdin);	/* clear any stale EOF indication */
@@ -597,14 +598,11 @@ open_next_file(name, input)
       ++input->bad_count;
       return;
     }
+  else if (follow_symlinks)
+    input->in_file_name = follow_symlink (name);
 
   input->read_fn = read_file_line;
 
-  if (follow_symlinks)
-    input->in_file_name = follow_symlink (name);
-  else
-    input->in_file_name = name;
-
   if (in_place_extension)
     {
       int input_fd;


Paolo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.