diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-16 16:54:27 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-16 16:54:27 -0400 |
| commit | 67191b70789de3ef723561f26587903dc1dc698f (patch) | |
| tree | 6f5428c8d6c5ea8e52e83fab17c875035d8ea7de /stdlib/shell.c | |
| parent | b4a0fda409f49c44c3aaee40575b438f0dfbbbe4 (diff) | |
Fix shell escaping for arrays of paths
Diffstat (limited to 'stdlib/shell.c')
| -rw-r--r-- | stdlib/shell.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/stdlib/shell.c b/stdlib/shell.c index 7dcc9a0a..30dc7c6f 100644 --- a/stdlib/shell.c +++ b/stdlib/shell.c @@ -34,6 +34,17 @@ public Shell_t Shell$escape_text_array(Array_t texts) return Text$join(Text(" "), all_escaped); } +public Shell_t Shell$escape_path_array(Array_t paths) +{ + Array_t all_escaped = {}; + for (int64_t i = 0; i < paths.length; i++) { + Path_t path = *(Path_t*)(paths.data + i*paths.stride); + Text_t escaped = Shell$escape_path(path); + Array$insert(&all_escaped, &escaped, I(0), sizeof(Text_t)); + } + return Text$join(Text(" "), all_escaped); +} + public OptionalArray_t Shell$run_bytes(Shell_t command) { const char *cmd_str = Text$as_c_string(command); |
