sed: fix " echo /usr/lib | sed 's,\(^/\|\)[^/][^/]*,..,g' " bug

function                                             old     new   delta
process_files                                       2102    2091     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2009-08-17 01:35:04 +02:00
parent 16d1e3c26f
commit f210cff601
2 changed files with 33 additions and 19 deletions

View File

@@ -241,4 +241,11 @@ testing "sed 2d;2,1p (gnu compat)" \
"third\n" "" \
"first\nsecond\nthird\nfourth\n"
# Regex means: "match / at BOL or nothing, then one or more not-slashes".
# The bug was that second slash in /usr/lib was treated as "at BOL" too.
testing "sed beginning (^) matches only once" \
"sed 's,\(^/\|\)[^/][^/]*,>\0<,g'" \
">/usr</>lib<\n" "" \
"/usr/lib\n"
exit $FAILCOUNT