+ undef;
+}
+
+sub wait_requote ($$$) { # OnDestroy callback
+ my ($lei, $pid, $old_1) = @_;
+ $lei->{1} = $old_1; # closes stdin of `perl -pE 's/^/> /'`
+ waitpid($pid, 0) == $pid or die "BUG(?) waitpid: \$!=$! \$?=$?";
+ $lei->child_error($?) if $?;
+}
+
+sub requote ($$) {
+ my ($lei, $pfx) = @_;
+ pipe(my($r, $w)) or die "pipe: $!";
+ my $rdr = { 0 => $r, 1 => $lei->{1}, 2 => $lei->{2} };
+ # $^X (perl) is overkill, but maybe there's a weird system w/o sed
+ my $pid = spawn([$^X, '-pE', "s/^/$pfx/"], $lei->{env}, $rdr);
+ my $old_1 = $lei->{1};
+ $w->autoflush(1);
+ binmode $w, ':utf8';
+ $lei->{1} = $w;
+ PublicInbox::OnDestroy->new(\&wait_requote, $lei, $pid, $old_1);