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 77F9D1FA17 for ; Fri, 16 Apr 2021 23:10:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/9] lei: fix rel2abs Date: Fri, 16 Apr 2021 16:10:32 -0700 Message-Id: <20210416231035.31807-7-e@80x24.org> In-Reply-To: <20210416231035.31807-1-e@80x24.org> References: <20210416231035.31807-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We don't want pathnames with "GLOB(0xADD12355)" in them. --- lib/PublicInbox/LEI.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 52b588a2..ebd0f154 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -68,18 +68,19 @@ sub rel2abs ($$) { my ($self, $p) = @_; return $p if index($p, '/') == 0; # already absolute my $pwd = $self->{env}->{PWD}; + my $cwd; if (defined $pwd) { - my $cwd = $self->{3} // getcwd() // die "getcwd(PWD=$pwd): $!"; + my $xcwd = $self->{3} // + ($cwd = getcwd() // die "getcwd(PWD=$pwd): $!"); if (my @st_pwd = stat($pwd)) { - my @st_cwd = stat($cwd) or die "stat($cwd): $!"; + my @st_cwd = stat($xcwd) or die "stat($xcwd): $!"; "@st_pwd[1,0]" eq "@st_cwd[1,0]" or - $self->{env}->{PWD} = $pwd = $cwd; + $self->{env}->{PWD} = $pwd = undef; } else { # PWD was invalid - delete $self->{env}->{PWD}; - undef $pwd; + $self->{env}->{PWD} = $pwd = undef; } } - $pwd //= $self->{env}->{PWD} = getcwd() // die "getcwd(PWD=$pwd): $!"; + $pwd //= $self->{env}->{PWD} = $cwd // getcwd() // die "getcwd: $!"; File::Spec->rel2abs($p, $pwd); }