aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-13 16:59:50 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-13 16:59:50 -0400
commit2442dca95164ba0db42877b80040ea9c7772a7f9 (patch)
tree8ac422bb5064783d4637f51930d0a5df5acbef85 /src
parentf0b81af6c273c0281e6802bc0f5af756f874cc9f (diff)
Expand `$HOME` when resolving home directory
Diffstat (limited to 'src')
-rw-r--r--src/common/util.odin25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/common/util.odin b/src/common/util.odin
index c702651..94348fb 100644
--- a/src/common/util.odin
+++ b/src/common/util.odin
@@ -58,17 +58,24 @@ resolve_home_dir :: proc(
when ODIN_OS == .Windows {
return path, false
} else {
- if !strings.has_prefix(path, "~") {
- return path, false
- }
+ if strings.has_prefix(path, "~") {
+ home := os.get_env("HOME", context.temp_allocator)
+ if home == "" {
+ log.error("could not find $HOME in the environment to be able to resolve ~ in collection paths")
+ return path, false
+ }
- home := os.get_env("HOME", context.temp_allocator)
- if home == "" {
- log.error("could not find $HOME in the environment to be able to resolve ~ in collection paths")
- return path, false
- }
+ return filepath.join({home, path[1:]}, allocator), true
+ } else if strings.has_prefix(path, "$HOME") {
+ home := os.get_env("HOME", context.temp_allocator)
+ if home == "" {
+ log.error("could not find $HOME in the environment to be able to resolve $HOME in collection paths")
+ return path, false
+ }
- return filepath.join({home, path[1:]}, allocator), true
+ return filepath.join({home, path[5:]}, allocator), true
+ }
+ return path, false
}
}