diff --git a/editors/sed.c b/editors/sed.c index a6845a979..e8c82ac63 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -435,8 +435,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) switch (substr[idx]) { /* Replace all occurrences */ case 'g': - if (match[0] != '^') - sed_cmd->which_match = 0; + sed_cmd->which_match = 0; break; /* Print pattern space */ case 'p': diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 67ff87e93..2b78c9b12 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests @@ -399,6 +399,12 @@ testing "sed uses previous regexp" \ "" \ "q\nw\ne\nr\n" +testing "sed ^ OR not^" \ + "sed -e 's/^a\|b//g'" \ + "ca\n" \ + "" \ + "abca\n" + # testing "description" "commands" "result" "infile" "stdin" exit $FAILCOUNT