mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 01:32:08 +00:00
Fix sed 's' command's 'p' flag, so it can print line twice
This commit is contained in:
parent
b08e3e8c2e
commit
ccd43a8301
@ -792,25 +792,23 @@ static void process_file(FILE *file)
|
|||||||
* flag exists in the first place.
|
* 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 */
|
/* 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);
|
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
|
/* we also print the line if we were given the 'p' flag
|
||||||
* (this is quite possibly the second printing) */
|
* (this is quite possibly the second printing) */
|
||||||
if (sed_cmd->sub_p)
|
if (sed_cmd->sub_p) {
|
||||||
altered |= do_subst_command(sed_cmd, &line);
|
altered |= do_subst_command(sed_cmd, &line);
|
||||||
if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's')))
|
if (altered) {
|
||||||
puts(line);
|
puts(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
puts(line);
|
puts(line);
|
||||||
fputs(sed_cmd->editline, stdout);
|
fputs(sed_cmd->editline, stdout);
|
||||||
|
Loading…
Reference in New Issue
Block a user