Skip to content

Commit

Permalink
fix: works when ran through a symlink
Browse files Browse the repository at this point in the history
closes #849
  • Loading branch information
EDM115 authored Aug 25, 2024
1 parent 465ed6d commit 0d7373a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ if ($ON_WINDOWS and $ENV{'SHELL'}) {
}
}

use Cwd "abs_path";
use File::Spec;
my $exec_path = abs_path($0);
# Fix for issues when runing cloc through a symlink on Windows
# e.g. : it have been installed with Winget
# See https://github.com/AlDanial/cloc/issues/849
if ($ON_WINDOWS) {
if (-l $0) {
$exec_path = abs_path(readlink($0));
}
$0 = $exec_path;
}

my $HAVE_Win32_Long_Path = 0;
# Win32::LongPath is an optional dependency that when available on
# Windows will be used to support reading files past the 255 char
Expand Down

0 comments on commit 0d7373a

Please sign in to comment.