MCPcopy Create free account
hub / github.com/Singular/Singular / ShellEscape

Function ShellEscape

ppcc/adlib/os.cc:85–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83INIT(_AdLibOS, InitSafeChars(););
84
85Str *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
107Str *BuildCommand(Str *prog, StrArr *args) {
108 Str *command = new Str(1024);

Callers 1

BuildCommandFunction · 0.85

Calls 2

lenMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected