Skip to content

Commit a3bb558

Browse files
authored
feat: evaluate symbolic link real path (#40)
1 parent c1e985f commit a3bb558

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

session/path.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"path"
7+
"path/filepath"
78

89
"github.com/joshmedeski/sesh/dir"
910
"github.com/joshmedeski/sesh/tmux"
@@ -19,7 +20,18 @@ func DeterminePath(choice string) (string, error) {
1920
return cwd, nil
2021
}
2122
fullPath := dir.FullPath(choice)
22-
if path.IsAbs(fullPath) {
23+
24+
realPath, err := filepath.EvalSymlinks(choice)
25+
if err != nil {
26+
fmt.Println("Couldn't evaluate symbolic link", err)
27+
os.Exit(1)
28+
}
29+
30+
if path.IsAbs(realPath) {
31+
return realPath, nil
32+
}
33+
34+
if path.IsAbs(realPath) {
2335
return fullPath, nil
2436
}
2537

0 commit comments

Comments
 (0)