From ed6362d731483ecd26d70b8fb482d5c2a33c5859 Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Fri, 12 Sep 2025 16:29:56 -0400 Subject: [PATCH] System/Core/Shell: Return full expanded path (including mount point) in @shell_expand_relative_path --- System/Core/Shell.HC | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/System/Core/Shell.HC b/System/Core/Shell.HC index cb069f6..533b5f9 100644 --- a/System/Core/Shell.HC +++ b/System/Core/Shell.HC @@ -79,12 +79,9 @@ I64 @shell_parse_opts(@shell* sh, U8* op_lst, I64 argc, U8** argv, I64* flags, } return 0; } -U8* @shell_expand_relative_path(@shell* sh, U8* path) + +U8* @shell_expand_relative_path_to_root_path(@shell* sh, U8* path) { - if (!path || !sh) - return NULL; - if (StrLen(path) < 1) - return NULL; switch (path[0]) { case '/': return StrNew(path); @@ -97,6 +94,24 @@ U8* @shell_expand_relative_path(@shell* sh, U8* path) } } +U8* @shell_expand_relative_path(@shell* sh, U8* path) +{ + if (!path || !sh) + return NULL; + if (StrLen(path) < 1) + return NULL; + U8* relative_path_to_root_path = @shell_expand_relative_path_to_root_path(sh, path); + if (!MemCmp(relative_path_to_root_path, "/mnt/", 5)) + return relative_path_to_root_path; + if (!MemCmp(relative_path_to_root_path, "/sys/", 5)) + return relative_path_to_root_path; + U8* prepend_root_path = config->o("default")->o("filesystem")->@("root"); + U8* full_expanded_path = CAlloc(StrLen(relative_path_to_root_path) + StrLen(prepend_root_path) + 8); + StrPrint(full_expanded_path, "%s%s", prepend_root_path, relative_path_to_root_path); + Free(relative_path_to_root_path); + return full_expanded_path; +} + U8* @shell_get_env_var(@shell* sh, U8* key) { @shell_env_var* var = sh->env->next;