MCPcopy Create free account
hub / github.com/Icinga/icinga2 / EscapeShellArg

Method EscapeShellArg

lib/base/utility.cpp:1229–1258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1227}
1228
1229String Utility::EscapeShellArg(const String& s)
1230{
1231 String result;
1232
1233#ifdef _WIN32
1234 result = "\"";
1235#else /* _WIN32 */
1236 result = "'";
1237#endif /* _WIN32 */
1238
1239 for (char ch : s) {
1240#ifdef _WIN32
1241 if (ch == '"' || ch == '%') {
1242 result += ' ';
1243 }
1244#else /* _WIN32 */
1245 if (ch == '\'')
1246 result += "'\\'";
1247#endif
1248 result += ch;
1249 }
1250
1251#ifdef _WIN32
1252 result += '"';
1253#else /* _WIN32 */
1254 result += '\'';
1255#endif /* _WIN32 */
1256
1257 return result;
1258}
1259
1260#ifdef _WIN32
1261String Utility::EscapeCreateProcessArg(const String& arg)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected