]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: {quiet} only affects normal command exit
authorEric Wong <e@80x24.org>
Thu, 19 Jan 2023 20:32:34 +0000 (20:32 +0000)
committerEric Wong <e@80x24.org>
Thu, 19 Jan 2023 20:54:21 +0000 (20:54 +0000)
{quiet} is nice for quieting normal/expected errors (e.g `git diff'),
but we still want to show the command in case there's errors in
our own code.

lib/PublicInbox/Qspawn.pm

index 78afe718d26dd21ce0d49ec60d86679d92a5f146..c4708c0fe035088aa7de392d7244aabf1d370d2e 100644 (file)
@@ -57,7 +57,8 @@ sub _do_spawn {
                        $o{$k} = $rlimit;
                }
        }
-       $self->{cmd} = $o{quiet} ? undef : $cmd;
+       $self->{cmd} = $cmd;
+       $self->{-quiet} = 1 if $o{quiet};
        $o{cb_arg} = [ \&waitpid_err, $self ];
        eval {
                # popen_rd may die on EMFILE, ENFILE
@@ -85,7 +86,7 @@ sub finalize ($) {
                if (my $dst = $self->{qsp_err}) {
                        $$dst .= $$dst ? " $err" : "; $err";
                }
-               warn "@{$self->{cmd}}: $err" if $self->{cmd};
+               warn "@{$self->{cmd}}: $err" if !$self->{-quiet};
        }
 
        my ($env, $qx_cb, $qx_arg, $qx_buf) =
@@ -216,9 +217,8 @@ sub rd_hdr ($) {
                                warn "parse_hdr: $@";
                                $ret = [ 500, [], [ "Internal error\n" ] ];
                        } elsif (!defined($ret) && !$r) {
-                               my $cmd = $self->{cmd} // [ '(?)' ];
                                warn <<EOM;
-EOF parsing headers from @$cmd ($self->{psgi_env}->{REQUEST_URI})
+EOF parsing headers from @{$self->{cmd}} ($self->{psgi_env}->{REQUEST_URI})
 EOM
                                $ret = [ 500, [], [ "Internal error\n" ] ];
                        }