Skip to content

Commit

Permalink
Escape spaces in shell command tokens (#281)
Browse files Browse the repository at this point in the history
Escape embedded spaces in tokens for shell command
  • Loading branch information
pjknowles authored Feb 10, 2024
1 parent 239218b commit 175da2f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sjef/util/util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SJEF_LIB_UTIL_UTIL_H_
#define SJEF_LIB_UTIL_UTIL_H_
#include <ostream>
#include <regex>

namespace sjef::util {

Expand All @@ -18,6 +19,7 @@ inline std::vector<std::string> splitString(const std::string& input, char c = '
result.emplace_back(begin + 1, str - 1);
else
result.emplace_back(begin, str);
result.back() = std::regex_replace(result.back(),std::regex{" "},"\\ ");
if (result.back().empty())
result.pop_back();
} while (0 != *str++);
Expand Down

0 comments on commit 175da2f

Please sign in to comment.