shell stuff, preprocessor directive

This commit is contained in:
udo
2022-01-21 22:22:14 +00:00
parent 3e8f0f1fa7
commit 939009f9a1
22 changed files with 342 additions and 54 deletions
+18 -3
View File
@@ -32,7 +32,19 @@ String shell_exec(String cmd)
String shell_escape(String raw)
{
// FIXME
return("\"" + raw + "\"");
String result = "";
for(auto c : raw)
{
if(c == '\'')
{
result.append("'\\''");
}
else
{
result.append(1, c);
}
}
return("\'" + result + "\'");
/*
` U+0060 (Grave Accent) Backtick Command substitution
~ U+007E Tilde Tilde expansion
@@ -164,11 +176,14 @@ void unlink(String file_name)
remove(file_name.c_str());
}
String expand_path(String path)
String expand_path(String path, String relative_to_path)
{
String result;
auto base_path = split(get_cwd(), "/");
if(relative_to_path == "")
relative_to_path = get_cwd();
auto base_path = split(relative_to_path, "/");
auto rel_path = split(path, "/");
for(auto& s : rel_path)