Fix shell escaping for arrays of paths
This commit is contained in:
parent
b4a0fda409
commit
67191b7078
@ -583,7 +583,7 @@ env_t *new_compilation_unit(CORD libname)
|
|||||||
{"Shell$escape_text", "func(text:Text -> Shell)"},
|
{"Shell$escape_text", "func(text:Text -> Shell)"},
|
||||||
{"Shell$escape_path", "func(path:Path -> Shell)"},
|
{"Shell$escape_path", "func(path:Path -> Shell)"},
|
||||||
{"Shell$escape_text_array", "func(texts:[Text] -> Shell)"},
|
{"Shell$escape_text_array", "func(texts:[Text] -> Shell)"},
|
||||||
{"Shell$escape_text_array", "func(paths:[Path] -> Shell)"},
|
{"Shell$escape_path_array", "func(paths:[Path] -> Shell)"},
|
||||||
{"Int$value_as_text", "func(i:Int -> Shell)"});
|
{"Int$value_as_text", "func(i:Int -> Shell)"});
|
||||||
ADD_CONSTRUCTORS("CString", {"Text$as_c_string", "func(text:Text -> CString)"});
|
ADD_CONSTRUCTORS("CString", {"Text$as_c_string", "func(text:Text -> CString)"});
|
||||||
ADD_CONSTRUCTORS("Moment",
|
ADD_CONSTRUCTORS("Moment",
|
||||||
|
@ -34,6 +34,17 @@ public Shell_t Shell$escape_text_array(Array_t texts)
|
|||||||
return Text$join(Text(" "), all_escaped);
|
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)
|
public OptionalArray_t Shell$run_bytes(Shell_t command)
|
||||||
{
|
{
|
||||||
const char *cmd_str = Text$as_c_string(command);
|
const char *cmd_str = Text$as_c_string(command);
|
||||||
|
@ -20,6 +20,7 @@ OptionalClosure_t Shell$by_line(Shell_t command);
|
|||||||
Shell_t Shell$escape_text(Text_t text);
|
Shell_t Shell$escape_text(Text_t text);
|
||||||
Shell_t Shell$escape_path(Path_t path);
|
Shell_t Shell$escape_path(Path_t path);
|
||||||
Shell_t Shell$escape_text_array(Array_t texts);
|
Shell_t Shell$escape_text_array(Array_t texts);
|
||||||
|
Shell_t Shell$escape_path_array(Array_t paths);
|
||||||
OptionalArray_t Shell$run_bytes(Shell_t command);
|
OptionalArray_t Shell$run_bytes(Shell_t command);
|
||||||
OptionalText_t Shell$run(Shell_t command);
|
OptionalText_t Shell$run(Shell_t command);
|
||||||
OptionalInt32_t Shell$execute(Shell_t command);
|
OptionalInt32_t Shell$execute(Shell_t command);
|
||||||
|
Loading…
Reference in New Issue
Block a user