Open tinyhare opened 1 month ago
I think the problem is at here: https://github.com/mirror/sed/blob/8edd37f3c5400b7a2c33003f070b420ebee4d832/sed/compile.c#L284
it reads all chars after 'r' command as the file name, it stoped only at the EOF and '\n'. so if I add a new line, it will ok:
root@house:~# echo -e "aaaaa\nBBBBB\nccccc" | sed '/BBBBB/ {r file.txt
> d}'
aaaaa
bbbbb
ccccc
In the code, there is someone seems want to solve some problems and 'had second thoughts' at last. ;-( I add some characters in the while condition to leave the loop. I don't know whether it has sideffects but it workd now.
read_filename (void)
{
struct buffer *b;
int ch;
if (sandbox)
bad_prog ("e/r/w commands disabled in sandbox mode");
b = init_buffer ();
ch = in_nonblank ();
// while (ch != EOF && ch != '\n')
while (ch != EOF && ch != '\n' && ch != ' ' && ch != ';' && ch != '}')
{
#if 0 /*XXX ZZZ 1998-09-12 kpp: added, then had second thoughts*/
if (posixicity == POSIXLY_EXTENDED)
if (ch == ';' || ch == '#')
{
savchar (ch);
break;
}
#endif
ch = add_then_next (b, ch);
}
add1_buffer (b, '\0');
return b;
}
./configure && make
root@house:~# echo -e "aaaaa\nBBBBB\nccccc" | sed '/BBBBB/ {r file.txt;d}'
sed: -e expression #1, char 0: unmatched `{'
root@house:~# echo -e "aaaaa\nBBBBB\nccccc" | /tmp/sed-4.9/sed/sed '/BBBBB/ {r file.txt;d}'
aaaaa
bbbbb
ccccc
root@house:~#
Does anyone have a better suggestion?