File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -92,12 +92,35 @@ extension SwiftlyCommand {
9292 continue
9393 }
9494
95- let potentialProxyPath = swiftlyBinDir / file
96- if let linkTarget = try ? await fs. readlink ( atPath: potentialProxyPath) , linkTarget == proxyTo {
95+ if await ( swiftlyBinDir / file) . linksTo ( proxyTo) {
9796 return true
9897 }
9998 }
10099
101100 return false
102101 }
103102}
103+
104+ extension FilePath {
105+ fileprivate func linksTo( _ other: FilePath ) async -> Bool {
106+ var path = self
107+ var jumps = 0
108+ while jumps < 10 { // More than 10 jumps is probably a symlink loop.
109+ if path == other {
110+ return true
111+ }
112+ jumps += 1
113+ do {
114+ let jumpTarget = try await fs. readlink ( atPath: path)
115+ path = if jumpTarget. isAbsolute {
116+ jumpTarget
117+ } else {
118+ path. parent. pushing ( jumpTarget) . lexicallyNormalized ( )
119+ }
120+ } catch {
121+ break
122+ }
123+ }
124+ return false
125+ }
126+ }
You can’t perform that action at this time.
0 commit comments