diff --git a/environment.c b/environment.c index 78525b0..9b39caa 100644 --- a/environment.c +++ b/environment.c @@ -581,7 +581,7 @@ env_t *new_compilation_unit(CORD libname) {"Int$value_as_text", "func(i:Int -> Path)"}); ADD_CONSTRUCTORS("Shell", {"Shell$escape_text", "func(text:Text -> Shell)"}, - {"Shell$escape_text", "func(path:Path -> Shell)"}, + {"Shell$escape_path", "func(path:Path -> Shell)"}, {"Shell$escape_text_array", "func(texts:[Text] -> Shell)"}, {"Shell$escape_text_array", "func(paths:[Path] -> Shell)"}, {"Int$value_as_text", "func(i:Int -> Shell)"}); diff --git a/stdlib/shell.c b/stdlib/shell.c index 7c54950..7dcc9a0 100644 --- a/stdlib/shell.c +++ b/stdlib/shell.c @@ -6,6 +6,7 @@ #include "arrays.h" #include "integers.h" +#include "paths.h" #include "patterns.h" #include "shell.h" #include "text.h" @@ -17,6 +18,11 @@ public Shell_t Shell$escape_text(Text_t text) return Texts(Text("'"), Text$replace(text, Text("'"), Text("'\"'\"'"), Text(""), false), Text("'")); } +public Shell_t Shell$escape_path(Path_t path) +{ + return Shell$escape_text(Path$as_text(&path, false, &Path$info)); +} + public Shell_t Shell$escape_text_array(Array_t texts) { Array_t all_escaped = {}; diff --git a/stdlib/shell.h b/stdlib/shell.h index 500bb04..c20c809 100644 --- a/stdlib/shell.h +++ b/stdlib/shell.h @@ -18,6 +18,7 @@ OptionalClosure_t Shell$by_line(Shell_t command); Shell_t Shell$escape_text(Text_t text); +Shell_t Shell$escape_path(Path_t path); Shell_t Shell$escape_text_array(Array_t texts); OptionalArray_t Shell$run_bytes(Shell_t command); OptionalText_t Shell$run(Shell_t command);