Skip to content

Commit

Permalink
Merge pull request #850 from EDM115/master
Browse files Browse the repository at this point in the history
fix: works when ran through a symlink, #849
  • Loading branch information
AlDanial authored Aug 25, 2024
2 parents 465ed6d + 237c5e3 commit 1f11b89
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Unix/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ https://github.com/Inventitech
https://github.com/zhangzqs
https://github.com/drkameleon
https://github.com/jackos
https://github.com/Aerek-Yasa
https://github.com/Aerek-Yasa
https://github.com/EDM115
13 changes: 13 additions & 0 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ if ($ON_WINDOWS and $ENV{'SHELL'}) {
}
}

use Cwd "abs_path";
use File::Spec;
# 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) {
my $exec_path = abs_path($0);
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
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;
# 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) {
my $exec_path = abs_path($0);
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 1f11b89

Please sign in to comment.