diff options
| author | Autumn | 2026-08-23 21:43:12 +0100 |
|---|---|---|
| committer | Autumn | 2026-08-23 21:43:12 +0100 |
| commit | f1288ac437097c6586e052d2eb28a9b3d112b40a (patch) | |
| tree | 77bc22b11aef7eba728289b59bdad10d58729326 /lib | |
| parent | 9d82d1fc84ca2a98b755444bae8de3abc3cafdde (diff) | |
[bunnytask] shell-expand file path resolution
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/config.ha | 13 |
1 files changed, 11 insertions, 2 deletions
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)?)?; }; }; |
