Skip to content

fix: works when ran through a symlink #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: see #850
- also edited the file in Unix dir as I believe they shouldn't be different
- edited Unix/AUTHORS
  • Loading branch information
EDM115 committed Aug 25, 2024
commit 237c5e34f147e121cb1eb2fb8404f8045b18164e
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
2 changes: 1 addition & 1 deletion cloc
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ 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) {
my $exec_path = abs_path($0);
if (-l $0) {
$exec_path = abs_path(readlink($0));
}
Expand Down