| 83 | INIT(_AdLibOS, InitSafeChars();); |
| 84 | |
| 85 | Str *ShellEscape(Str *arg) { |
| 86 | int safe = 1; |
| 87 | for (Int i = 0; i < arg->len(); i++) { |
| 88 | if (!safe_chars[arg->byte(i)]) { |
| 89 | safe = 0; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | if (safe) |
| 94 | return arg; |
| 95 | Str *result = new Str(arg->len()); |
| 96 | result->add('\''); |
| 97 | for (Str::Each it(arg); it; ++it) { |
| 98 | if (*it == '\'') |
| 99 | result->add("'\\''"); |
| 100 | else |
| 101 | result->add(*it); |
| 102 | } |
| 103 | result->add('\''); |
| 104 | return result; |
| 105 | } |
| 106 | |
| 107 | Str *BuildCommand(Str *prog, StrArr *args) { |
| 108 | Str *command = new Str(1024); |
no test coverage detected