1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 08:11:47 +02:00

Merge pull request #13065 from roberth/escapeShellArg

Rename `shellEscape` -> `escapeShellArgAlways`
This commit is contained in:
Robert Hensing 2025-04-23 23:35:15 +02:00 committed by GitHub
commit 8a1c40b927
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 20 deletions

View file

@ -152,8 +152,13 @@ std::string toLower(std::string s);
/**
* Escape a string as a shell word.
*
* This always adds single quotes, even if escaping is not strictly necessary.
* So both
* - `"hello world"` -> `"'hello world'"`, which needs escaping because of the space
* - `"echo"` -> `"'echo'"`, which doesn't need escaping
*/
std::string shellEscape(const std::string_view s);
std::string escapeShellArgAlways(const std::string_view s);
/**

View file

@ -171,7 +171,7 @@ std::string toLower(std::string s)
}
std::string shellEscape(const std::string_view s)
std::string escapeShellArgAlways(const std::string_view s)
{
std::string r;
r.reserve(s.size() + 2);