From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C03D91F4B4 for ; Sat, 17 Apr 2021 10:00:18 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/9] lei_query: fix relative path handling on --stdin Date: Sat, 17 Apr 2021 10:00:17 +0000 Message-Id: <20210417100017.77316-1-e@80x24.org> In-Reply-To: <20210417022409.81869-1-e@80x24.org> References: <20210417022409.81869-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since --stdin could be waiting on user keyboard input or something else slow, we handle it in the event loop. That means other commands can change the working directory of lei-daemon while a query is being trickled to us via stdin. Rearranging query handling internals to delay opening the --output destination in commit 26e0fe73de93f451 meant another command could throw off our --output pathname if it is relative. Fixes: 26e0fe73de93f451 ("lei_query: rearrange internals to capture query early") --- lib/PublicInbox/LeiQuery.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 7ddba4cf..385ba0a9 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -53,6 +53,9 @@ sub qstr_add { # PublicInbox::InputPipe::consume callback for --stdin my ($self) = @_; # $_[1] = $rbuf if (defined($_[1])) { $_[1] eq '' and return eval { + if (my $dfd = $self->{3}) { + chdir($dfd) or return $self->fail("fchdir: $!"); + } $self->{mset_opt}->{q_raw} = $self->{mset_opt}->{qstr}; $self->{lse}->query_approxidate($self->{lse}->git, $self->{mset_opt}->{qstr});