From de7ca3aab3b1c63e62d44061e8bb7409c03d7c05 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 8 May 2020 13:13:26 +0100 Subject: [PATCH] nailing-cargo: Search for TOML::Tiny near our (actual) script Signed-off-by: Ian Jackson --- nailing-cargo | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/nailing-cargo b/nailing-cargo index 60e5091..1a31568 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -39,13 +39,32 @@ # [subdirs] # subdir +our $self; + use strict; -use TOML::Tiny::Faithful; use POSIX; + +BEGIN { + $self = $0; $self =~ s{^.*/(?=.)}{}; + my $deref = $0; + while ($deref =~ m{^/}) { + my $link = readlink $deref; + if (!defined $link) { + $! == EINVAL + or die "$self: checking our script location $deref: $!\n"; + $deref =~ s{/[^/]+$}{} + or die "$self: unexpected script path: $deref\n"; + unshift @INC, $deref."/TOML-Tiny/lib"; + last; + } + last if $link !~ m{^/}; + $deref = $link; + } +} + use Fcntl qw(LOCK_EX); use File::Compare; - -my $self = $0; $self =~ s{^.*/(?=.)}{}; +use TOML::Tiny::Faithful; our $worksphere = getcwd() // die "$self: getcwd failed: $!\n"; $worksphere =~ s{/[^/]+$}{} or die "$self: cwd \`$worksphere' unsupported!\n"; -- 2.30.2