aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c2
-rwxr-xr-xtestsuite/sed.tests1
2 files changed, 2 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 4e9babb9d..429c1ed58 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -741,7 +741,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
741 * The match_count check is so not to break 741 * The match_count check is so not to break
742 * echo "hi" | busybox sed 's/^/!/g' 742 * echo "hi" | busybox sed 's/^/!/g'
743 */ 743 */
744 if (!G.regmatch[0].rm_so && !G.regmatch[0].rm_eo && match_count) { 744 if (!G.regmatch[0].rm_so && !G.regmatch[0].rm_eo && match_count && *line) {
745 pipe_putc(*line++); 745 pipe_putc(*line++);
746 continue; 746 continue;
747 } 747 }
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index ba163e9e9..9fa8e190c 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -48,6 +48,7 @@ testing "sed accepts multiple -e" "sed -e 'i\' -e '1' -e 'a\' -e '3'" \
48 48
49# substitutions 49# substitutions
50testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n" 50testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n"
51testing "sed with empty match" "sed 's/z*//g'" "string\n" "" "string\n"
51testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \ 52testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \
52 "" "foo\n" 53 "" "foo\n"
53testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n" 54testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n"