[BusyBox] busybox-1-0pre2 sed problem
Jean Wolter
jean.wolter at inf.tu-dresden.de
Sat Aug 23 22:20:05 UTC 2003
Hello,
I am not quite sure what the right behaviour should be, but the
following command IMHO doesn't produce the right output:
echo foobar | sed -n 's/foo//;s/bar/found/p'
found
echo fooba | sed -n 's/foo//;s/bar/found/p'
ba
It always prints the pattern space if the first substition changed the
pattern space. The manual says:
`p'
If the substitution was made, then print the new pattern
space.
But since the second substitution wasn't made it shouldn't print
anything.
A simple fix for this specific problem would be to simply reset the
altered flag before executing a single command:
--- editors/sed.c 23 Aug 2003 09:31:46 -0000 1.1.1.1
+++ editors/sed.c 23 Aug 2003 22:17:58 -0000
@@ -840,6 +840,7 @@
&& (next_line == NULL))
);
+ altered = 0;
if (sed_cmd->cmd == '{') {
block_mask = block_mask & matched;
}
regards,
Jean
More information about the busybox
mailing list