Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:matwey:experimental:Leap:42.2:Rings:0
sed
sed-follow-symlinks-stdin.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sed-follow-symlinks-stdin.patch of Package sed
This is a backport of the fix itself. From e387009c78fa08aaebf5192a3ceeb04dcfc7781d Mon Sep 17 00:00:00 2001 From: Stanislav Brabec <sbrabec@suse.com> Date: Mon, 13 Jul 2015 22:59:17 +0200 Subject: [PATCH] sed: fix --follow-symlinks to work when reading stdin When reading from stdin, use of --follow-symlinks would cause failure: $ echo abc | sed --follow-symlinks s/a/d/ sed: cannot stat -: No such file or directory * sed/execute.c (open_next_file): Set input->in_file_name earlier, so we can rearrange logic to avoid calling follow_symlink("-"). * testsuite/follow-symlinks-stdin.sh: New file. * testsuite/Makefile.am (T): Add it. * NEWS (Bug fixes): Mention it. Bug introduced by commit v4.2.1-13-g84066bf. http://bugs.gnu.org/20795 --- NEWS | 3 +++ sed/execute.c | 24 +++++++++++++----------- testsuite/Makefile.am | 1 + testsuite/follow-symlinks-stdin.sh | 29 +++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100755 testsuite/follow-symlinks-stdin.sh Index: sed-4.2.2/sed/execute.c =================================================================== --- sed-4.2.2.orig/sed/execute.c +++ sed-4.2.2/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') { if (in_place_extension) @@ -592,22 +593,23 @@ open_next_file(name, input) input->fp = stdin; #endif } - else if ( ! (input->fp = ck_fopen(name, read_mode, false)) ) + else { - const char *ptr = strerror(errno); - fprintf(stderr, _("%s: can't read %s: %s\n"), myname, name, ptr); - input->read_fn = read_always_fail; /* a redundancy */ - ++input->bad_count; - return; + if (follow_symlinks) + input->in_file_name = follow_symlink (name); + + if ( ! (input->fp = ck_fopen (name, read_mode, false)) ) + { + const char *ptr = strerror (errno); + fprintf (stderr, _("%s: can't read %s: %s\n"), myname, name, ptr); + input->read_fn = read_always_fail; /* a redundancy */ + ++input->bad_count; + return; + } } 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;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor