Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ end

# try to call realpath on as much as possible
function safe_realpath(path)
isempty(path) && return path
if ispath(path)
try
return realpath(path)
Expand All @@ -128,6 +127,8 @@ function safe_realpath(path)
end
end
a, b = splitdir(path)
# path cannot be reduced at the root or drive, avoid stack overflow
isempty(b) && return path
return joinpath(safe_realpath(a), b)
end

Expand Down
3 changes: 2 additions & 1 deletion test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ end
end

@testset "safe_realpath" begin
realpath(Sys.BINDIR) == Pkg.safe_realpath(Sys.BINDIR)
# issue #3085
for p in ("", "some-non-existing-path")
for p in ("", "some-non-existing-path", "some-non-existing-drive:")
@test p == Pkg.safe_realpath(p)
end
end
Expand Down