aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c3
-rwxr-xr-xtestsuite/sed.tests6
2 files changed, 7 insertions, 2 deletions
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)
435 switch (substr[idx]) { 435 switch (substr[idx]) {
436 /* Replace all occurrences */ 436 /* Replace all occurrences */
437 case 'g': 437 case 'g':
438 if (match[0] != '^') 438 sed_cmd->which_match = 0;
439 sed_cmd->which_match = 0;
440 break; 439 break;
441 /* Print pattern space */ 440 /* Print pattern space */
442 case 'p': 441 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" \
399 "" \ 399 "" \
400 "q\nw\ne\nr\n" 400 "q\nw\ne\nr\n"
401 401
402testing "sed ^ OR not^" \
403 "sed -e 's/^a\|b//g'" \
404 "ca\n" \
405 "" \
406 "abca\n"
407
402# testing "description" "commands" "result" "infile" "stdin" 408# testing "description" "commands" "result" "infile" "stdin"
403 409
404exit $FAILCOUNT 410exit $FAILCOUNT