From f1288ac437097c6586e052d2eb28a9b3d112b40a Mon Sep 17 00:00:00 2001 From: Autumn Date: Sun, 23 Aug 2026 21:43:12 +0100 Subject: [bunnytask] shell-expand file path resolution --- lib/config.ha | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/config.ha') diff --git a/lib/config.ha b/lib/config.ha index def33dd..f974c26 100644 --- a/lib/config.ha +++ b/lib/config.ha @@ -4,6 +4,7 @@ use fs; use io; use strings; use os; +use wordexp; export type config = struct { files: []str }; @@ -15,7 +16,7 @@ fn load_item(scanner: *ini::scanner) (ini::entry | done) = { }; // caller must free after use using [[config_free]] -export fn config_read() (*config | fs::error | nomem) = { +export fn config_read() (*config | fs::error | wordexp::error | nomem) = { const config_file = dirs::config("bunnytask"); const config_file = strings::concat(config_file, "/config.ini")?; @@ -33,9 +34,17 @@ export fn config_read() (*config | fs::error | nomem) = { for (let entry => load_item(&scanner)) { if (strings::trim(entry.1) == "todo_file") { - // TODO shell expand + + // trim & make spaces shell-safe const file = strings::trim(entry.2); + const file = strings::replace(file, " ", "\\ ")?; + defer free(file); + + // shell expand + const file = wordexp::wordexp(file)?; + defer strings::freeall(file); + const file = file[0]; append(files, strings::dup(file)?)?; }; }; -- cgit v1.3