-sub lei_git { # support passing through random git commands
- my ($self, @argv) = @_;
- my %rdr = map { $_ => $self->{$_} } (0..2);
- my $pid = spawn(['git', @argv], $self->{env}, \%rdr);
- dwaitpid($pid, \&reap_exec, $self);
+sub start_mua {
+ my ($self) = @_;
+ my $mua = $self->{opt}->{'mua-cmd'} // return;
+ my $mfolder = $self->{ovv}->{dst};
+ my (@cmd, $replaced);
+ if ($mua =~ /\A(?:mutt|mailx|mail|neomutt)\z/) {
+ @cmd = ($mua, '-f');
+ # TODO: help wanted: other common FOSS MUAs
+ } else {
+ require Text::ParseWords;
+ my @cmd = Text::ParseWords::shellwords($mua);
+ # mutt uses '%f' for open-hook with compressed mbox, we follow
+ @cmd = map { $_ eq '%f' ? ($replaced = $mfolder) : $_ } @cmd;
+ }
+ push @cmd, $mfolder unless defined($replaced);
+ if (my $sock = $self->{sock}) { # lei(1) client process runs it
+ send($sock, exec_buf(\@cmd, {}), MSG_EOR);
+ } elsif ($self->{oneshot}) {
+ $self->{"mua.pid.$self.$$"} = spawn(\@cmd);
+ }
+ delete $self->{-progress};