aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-03-28 07:44:03 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-03-28 07:44:03 +0000
commitccd43a83014d77cda09b5af82de9996bcd1fa333 (patch)
tree0325e4d2e84e30f176d302e619f87d5f559eadb0
parentb08e3e8c2e1334ba00df7d818b586815b328a4b0 (diff)
downloadbusybox-ccd43a83014d77cda09b5af82de9996bcd1fa333.tar.gz
Fix sed 's' command's 'p' flag, so it can print line twice
-rw-r--r--editors/sed.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 78d46091f..d14b6f763 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -792,25 +792,23 @@ static void process_file(FILE *file)
* flag exists in the first place.
*/
- /* if the user specified that they didn't want anything printed (i.e., a -n
- * flag and no 'p' flag after the s///), then there's really no point doing
- * anything here. */
- if (be_quiet && !sed_cmd->sub_p)
- break;
-
/* we print the line once, unless we were told to be quiet */
- if (!be_quiet)
+ if (!be_quiet) {
altered |= do_subst_command(sed_cmd, &line);
+ if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's'))) {
+ puts(line);
+ }
+ }
/* we also print the line if we were given the 'p' flag
* (this is quite possibly the second printing) */
- if (sed_cmd->sub_p)
+ if (sed_cmd->sub_p) {
altered |= do_subst_command(sed_cmd, &line);
- if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's')))
- puts(line);
-
+ if (altered) {
+ puts(line);
+ }
+ }
break;
-
case 'a':
puts(line);
fputs(sed_cmd->editline, stdout);