Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2021-12-21 15:52:29 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-12-25 06:20:28 +0300
commit4fe954c14851d2f913c41c581cbe49300b0984e4 (patch)
treefc3efe9f530d28ba4ab7092a9d966c192ac49e59 /testsuite
parenta05a3d5932b5002d0513adfa817b931dcc1686c0 (diff)
sed: do not ignore 'g' modifier when match starts with ^
It is perfectly valid to start a regex with ^ and have other patterns with \| that can match more than once, e.g. the following example should print ca, as illustrated with gnu sed: $ echo 'abca' | sed -e 's/^a\|b//g' ca busybox before patch: $ echo 'abca' | busybox sed -e 's/^a\|b//g' bca busybox after patch: $ echo 'abca' | ./busybox sed -e 's/^a\|b//g' ca regcomp handles ^ perfectly well as illustrated with the second 'a' that did not match in the example, we ca leave the non-repeating to it if appropriate. The check had been added before using regcomp and was required at the time (f36635cec6da) but no longer makes sense now. (tested with glibc and musl libc) function old new delta add_cmd 1189 1176 -13 Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/sed.tests6
1 files changed, 6 insertions, 0 deletions
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