From 66cf12d17e9fa453b34bcd9d0b8dc4f1954e8cff Mon Sep 17 00:00:00 2001
From: anthraxx <levente@leventepolyak.net>
Date: Wed, 4 Sep 2019 01:56:47 +0200
Subject: [PATCH] pdf2john: allow symlinked usage by resolving script path

This resolves the script's real path which is then used to populate
the perl module include path to the appropriate location of the
vendored lib folder.
This allows using pdf2john anywhere as a symlink, f.e. inside $PATH.

Fixes #4089
---
 run/pdf2john.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/run/pdf2john.pl b/run/pdf2john.pl
index 383ab3134c..e8791c3e39 100755
--- a/run/pdf2john.pl
+++ b/run/pdf2john.pl
@@ -24,10 +24,11 @@
 my $version = '8.99';

 # add our 'lib' directory to the include list BEFORE 'use ExifTool'
+use Cwd qw(realpath);
 my $exeDir;
 BEGIN {
     # get exe directory
-    $exeDir = ($0 =~ /(.*)[\\\/]/) ? $1 : '.';
+    $exeDir = (realpath($0) =~ /(.*)[\\\/]/) ? $1 : '.';
     # add lib directory at start of include path
     unshift @INC, "$exeDir/lib";
     # load or disable config file if specified
