MCPcopy Create free account
hub / github.com/ElementsProject/elements / ShellQuote

Function ShellQuote

src/rpc/util.cpp:139–151  ·  view source on GitHub ↗

* Quote an argument for shell. * * @note This is intended for help, not for security-sensitive purposes. */

Source from the content-addressed store, hash-verified

137 * @note This is intended for help, not for security-sensitive purposes.
138 */
139std::string ShellQuote(const std::string& s)
140{
141 std::string result;
142 result.reserve(s.size() * 2);
143 for (const char ch: s) {
144 if (ch == '\'') {
145 result += "'\''";
146 } else {
147 result += ch;
148 }
149 }
150 return "'" + result + "'";
151}
152
153/**
154 * Shell-quotes the argument if it needs quoting, else returns it literally, to save typing.

Callers 1

ShellQuoteIfNeededFunction · 0.85

Calls 2

reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected