diff --git a/tests/sed.test b/tests/sed.test index 91f6b6e3..e3045f7e 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -179,6 +179,7 @@ testcmd '-z' '-z "s/\n/-/g"' "a-b-c" "" "a\nb\nc" testcmd '-z N' '-z N' 'one\0two\0' '' 'one\0two\0' testcmd 'p noeol' '-z p' 'one\0one' '' 'one' testcmd '-z N noeol' '-z N' 'one\0two' '' 'one\0two' +testcmd '-z S' "-z 'N;P'" 'one\0one\0two' '' 'one\0two' # toybox handling of empty capturing groups broke minjail. Check that we # correctly replace an empty capturing group with the empty string: diff --git a/toys/posix/sed.c b/toys/posix/sed.c index 471c6436..444c8682 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -408,7 +408,7 @@ static void sed_line(char **pline, long plen) // Pending append goes out right after N goto done; } else if (c=='p' || c=='P') { - char *l = (c=='P') ? strchr(line, '\n') : 0; + char *l = (c=='P') ? strchr(line, TT.delim) : 0; if (emit(line, l ? l-line : len, eol)) break; } else if (c=='q' || c=='Q') {