diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-28 07:44:03 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-28 07:44:03 +0000 |
commit | 7b07ff4ec2f5ca4aa9aa8f9c42997d7af7d91c18 (patch) | |
tree | 0325e4d2e84e30f176d302e619f87d5f559eadb0 | |
parent | 017ba063cdcb92c8353f9dfffca1330fda3c7c0c (diff) | |
download | busybox-w32-7b07ff4ec2f5ca4aa9aa8f9c42997d7af7d91c18.tar.gz busybox-w32-7b07ff4ec2f5ca4aa9aa8f9c42997d7af7d91c18.tar.bz2 busybox-w32-7b07ff4ec2f5ca4aa9aa8f9c42997d7af7d91c18.zip |
Fix sed 's' command's 'p' flag, so it can print line twice
git-svn-id: svn://busybox.net/trunk/busybox@6764 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | editors/sed.c | 22 |
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) | |||
792 | * flag exists in the first place. | 792 | * flag exists in the first place. |
793 | */ | 793 | */ |
794 | 794 | ||
795 | /* if the user specified that they didn't want anything printed (i.e., a -n | ||
796 | * flag and no 'p' flag after the s///), then there's really no point doing | ||
797 | * anything here. */ | ||
798 | if (be_quiet && !sed_cmd->sub_p) | ||
799 | break; | ||
800 | |||
801 | /* we print the line once, unless we were told to be quiet */ | 795 | /* we print the line once, unless we were told to be quiet */ |
802 | if (!be_quiet) | 796 | if (!be_quiet) { |
803 | altered |= do_subst_command(sed_cmd, &line); | 797 | altered |= do_subst_command(sed_cmd, &line); |
798 | if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's'))) { | ||
799 | puts(line); | ||
800 | } | ||
801 | } | ||
804 | 802 | ||
805 | /* we also print the line if we were given the 'p' flag | 803 | /* we also print the line if we were given the 'p' flag |
806 | * (this is quite possibly the second printing) */ | 804 | * (this is quite possibly the second printing) */ |
807 | if (sed_cmd->sub_p) | 805 | if (sed_cmd->sub_p) { |
808 | altered |= do_subst_command(sed_cmd, &line); | 806 | altered |= do_subst_command(sed_cmd, &line); |
809 | if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's'))) | 807 | if (altered) { |
810 | puts(line); | 808 | puts(line); |
811 | 809 | } | |
810 | } | ||
812 | break; | 811 | break; |
813 | |||
814 | case 'a': | 812 | case 'a': |
815 | puts(line); | 813 | puts(line); |
816 | fputs(sed_cmd->editline, stdout); | 814 | fputs(sed_cmd->editline, stdout); |