Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

3 views
Skip to first unread message

Luke T. Shumaker

unread,
Jan 9, 2013, 12:50:32 AM1/9/13
to bug...@gnu.org
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 new behavior is an inconvenience to users who may have created
an alias for sed, as I have:
alias sed='sed --follow-symlinks'

Version information:
$ 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...@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

Problem testcase:
$ type sed
sed is aliased to `sed --follow-symlinks'
$ sed s/foo/bar/ <<<foo
/bin/sed: cannot stat -: No such file or directory

$ /bin/sed --follow-symlinks s/foo/bar/ <<<foo
/bin/sed: cannot stat -: No such file or directory

Work-around 0:
$ /bin/sed s/foo/bar/ <<<foo
bar

Work-around 1:
$ unalias sed
$ sed s/foo/bar/ <<<foo
bar

Happy hacking,
~ Luke Shumaker

Paolo Bonzini

unread,
Jan 10, 2013, 10:12:59 AM1/10/13
to Luke T. Shumaker, bug...@gnu.org
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

0 new messages