summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2023-02-02 20:25:34 +0100
committerJoel Rosdahl <joel@rosdahl.net>2023-02-03 14:22:20 +0100
commit306aa8eebfe7f3442c176ed5ebd42f8767b0125c (patch)
tree7b1496cce5e31f6a1faa63f76b3297c3e63d40a1
parent320e2ea633c9373b4d10afc8bc9f373d4fb4ee67 (diff)
downloadccache-306aa8eebfe7f3442c176ed5ebd42f8767b0125c.tar.gz
feat: Add quotes around arguments with space in logged command lines
-rw-r--r--src/Util.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Util.cpp b/src/Util.cpp
index e1b0d865..82afba8d 100644
--- a/src/Util.cpp
+++ b/src/Util.cpp
@@ -525,9 +525,11 @@ format_argv_for_logging(const char* const* argv)
if (i != 0) {
result += ' ';
}
- for (const char* arg = argv[i]; *arg; ++arg) {
- result += *arg;
+ std::string arg(argv[i]);
+ if (arg.empty() || arg.find(' ') != std::string::npos) {
+ arg = FMT("\"{}\"", arg);
}
+ result += arg;
}
return result;
}