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

Rename shellEscape -> escapeShellArgAlways

This name is close to the Nixpkgs lib function `escapeShellArg`,
making it easier to find.

A friendlier function with the same behavior as lib could be added
later.
This commit is contained in:
Robert Hensing 2025-04-23 13:14:28 +02:00
parent f186491db9
commit 1e5b1d9973
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);