From: Joel Rosdahl Date: Thu, 2 Feb 2023 19:25:34 +0000 (+0100) Subject: feat: Add quotes around arguments with space in logged command lines X-Git-Tag: v4.8~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=306aa8eebfe7f3442c176ed5ebd42f8767b0125c;p=thirdparty%2Fccache.git feat: Add quotes around arguments with space in logged command lines --- diff --git a/src/Util.cpp b/src/Util.cpp index e1b0d865d..82afba8d8 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; }