aboutsummaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-28 00:30:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-28 00:30:09 -0400
commit8df8f5bb828d0cb730db717c6a89aafa9986ae55 (patch)
tree8b9f5eb30af2e91a699c5038e358a9a5d982b96c /builtins
parentcb634f61f78bb629164f98ea04ab04a8e5c5b67d (diff)
Changes to dependency tracking, compilation, and object linking
Diffstat (limited to 'builtins')
-rw-r--r--builtins/files.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/builtins/files.c b/builtins/files.c
index 2375fc8a..524a8626 100644
--- a/builtins/files.c
+++ b/builtins/files.c
@@ -41,13 +41,13 @@ public char *resolve_path(const char *path, const char *relative_to, const char
// Relative path:
char *relative_dir = dirname(heap_str(relative_to));
if (!system_path) system_path = ".";
- char *copy = strdup(system_path);
+ char *copy = heap_str(system_path);
for (char *dir, *pos = copy; (dir = strsep(&pos, ":")); ) {
if (dir[0] == '/') {
char *resolved = realpath(heap_strf("%s/%s", dir, path), buf);
if (resolved) return heap_str(resolved);
} else if (dir[0] == '~' && (dir[1] == '\0' || dir[1] == '/')) {
- char *resolved = realpath(heap_strf("%s%s/%s", getenv("HOME"), dir, path), buf);
+ char *resolved = realpath(heap_strf("%s%s/%s", getenv("HOME"), dir+1, path), buf);
if (resolved) return heap_str(resolved);
} else if (streq(dir, ".") || strncmp(dir, "./", 2) == 0) {
char *resolved = realpath(heap_strf("%s/%s", relative_dir, path), buf);
@@ -60,7 +60,6 @@ public char *resolve_path(const char *path, const char *relative_to, const char
if (resolved) return heap_str(resolved);
}
}
- free(copy);
}
return NULL;
}