aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-09-15 06:28:45 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-09-15 06:28:45 +0000
commit2eed0e2d470d7020e8bdec2a0f398a296192816b (patch)
tree6cac378079257eb4bb2c9364ecb2976720f4091e
parent6e5687abc3732fac6d8a43a324b8f284f7a5482d (diff)
downloadbusybox-w32-2eed0e2d470d7020e8bdec2a0f398a296192816b.tar.gz
busybox-w32-2eed0e2d470d7020e8bdec2a0f398a296192816b.tar.bz2
busybox-w32-2eed0e2d470d7020e8bdec2a0f398a296192816b.zip
Add a test for the 'P' command and fix current implementation so it
doesnt permanently modify the pattern space.
-rw-r--r--editors/sed.c4
-rw-r--r--testsuite/sed/sed-write-to-stdout10
2 files changed, 14 insertions, 0 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 8c77a0ffc..2b01ec7ff 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -857,7 +857,11 @@ static void process_file(FILE * file)
857 857
858 if (tmp) { 858 if (tmp) {
859 *tmp = '\0'; 859 *tmp = '\0';
860 puts(pattern_space);
861 *tmp = '\n';
862 break;
860 } 863 }
864 /* Fall Through */
861 } 865 }
862 case 'p': /* Write the current pattern space to output */ 866 case 'p': /* Write the current pattern space to output */
863 puts(pattern_space); 867 puts(pattern_space);
diff --git a/testsuite/sed/sed-write-to-stdout b/testsuite/sed/sed-write-to-stdout
new file mode 100644
index 000000000..95b4d724b
--- /dev/null
+++ b/testsuite/sed/sed-write-to-stdout
@@ -0,0 +1,10 @@
1busybox sed -n 'N;P;p'>output <<EOF
2a
3b
4c
5EOF
6cmp -s output - <<EOF
7a
8a
9b
10EOF