Add a test for the 'P' command and fix current implementation so it
authorGlenn L McGrath <bug1@ihug.co.nz>
Mon, 15 Sep 2003 06:28:45 +0000 (06:28 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Mon, 15 Sep 2003 06:28:45 +0000 (06:28 -0000)
doesnt permanently modify the pattern space.

editors/sed.c
testsuite/sed/sed-write-to-stdout [new file with mode: 0644]

index 8c77a0f..2b01ec7 100644 (file)
@@ -857,7 +857,11 @@ static void process_file(FILE * file)
 
                                        if (tmp) {
                                                *tmp = '\0';
+                                               puts(pattern_space);
+                                               *tmp = '\n';
+                                               break;
                                        }
+                                       /* Fall Through */
                                }
                                case 'p':       /* Write the current pattern space to output */
                                        puts(pattern_space);
diff --git a/testsuite/sed/sed-write-to-stdout b/testsuite/sed/sed-write-to-stdout
new file mode 100644 (file)
index 0000000..95b4d72
--- /dev/null
@@ -0,0 +1,10 @@
+busybox sed -n 'N;P;p'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+a
+a
+b
+EOF