summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDenys Vlasenko2015-04-17 14:24:55 +0200
committerDenys Vlasenko2015-04-17 14:24:55 +0200
commit63f4d32c9859c1ed341debefddad4b9c0ae944cc (patch)
treef386542a9330a9b480519d94779e0e6caf2664dd /testsuite
parent71a5b67ba0339265153217df646827a1213e03f5 (diff)
downloadbusybox-63f4d32c9859c1ed341debefddad4b9c0ae944cc.zip
busybox-63f4d32c9859c1ed341debefddad4b9c0ae944cc.tar.gz
sed: implement ",+N" range end
function old new delta add_cmd 1115 1173 +58 process_files 2226 2253 +27 sed_main 696 702 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 91/0) Total: 91 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/sed.tests32
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 19f2915..34479e5 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -333,6 +333,38 @@ testing "sed s///NUM test" \
"sed -e 's/a/b/2; s/a/c/g'" \
"cb\n" "" "aa\n"
+testing "sed /regex/,N{...} addresses work" \
+ "sed /^2/,2{d}" \
+ "1\n3\n4\n5\n" \
+ "" \
+ "1\n2\n3\n4\n5\n"
+
+testing "sed /regex/,+N{...} addresses work" \
+ "sed /^2/,+2{d}" \
+ "1\n5\n" \
+ "" \
+ "1\n2\n3\n4\n5\n"
+
+testing "sed /regex/,+N{...} -i works" \
+ "cat - >input2; sed /^4/,+2{d} -i input input2; echo \$?; cat input input2; rm input2" \
+ "0\n""1\n2\n3\n7\n8\n""1\n2\n7\n8\n" \
+ "1\n2\n3\n4\n5\n6\n7\n8\n" \
+ "1\n2\n4\n5\n6\n7\n8\n" \
+
+# GNU sed 4.2.1 would also accept "/^4/,+{d}" with the same meaning, we don't
+testing "sed /regex/,+0{...} -i works" \
+ "cat - >input2; sed /^4/,+0{d} -i input input2; echo \$?; cat input input2; rm input2" \
+ "0\n""1\n2\n3\n5\n6\n7\n8\n""1\n2\n5\n6\n7\n8\n" \
+ "1\n2\n3\n4\n5\n6\n7\n8\n" \
+ "1\n2\n4\n5\n6\n7\n8\n" \
+
+# GNU sed 4.2.1 would also accept "/^4/,+d" with the same meaning, we don't
+testing "sed /regex/,+0<cmd> -i works" \
+ "cat - >input2; sed /^4/,+0d -i input input2; echo \$?; cat input input2; rm input2" \
+ "0\n""1\n2\n3\n5\n6\n7\n8\n""1\n2\n5\n6\n7\n8\n" \
+ "1\n2\n3\n4\n5\n6\n7\n8\n" \
+ "1\n2\n4\n5\n6\n7\n8\n" \
+
# testing "description" "commands" "result" "infile" "stdin"
exit $FAILCOUNT