commands: fix prep commands when empty (#1083)
This commit is contained in:
parent
e1fddcc99c
commit
014ca7e8a1
1 changed files with 6 additions and 0 deletions
|
|
@ -762,12 +762,18 @@ void list_string_f(std::unordered_map<std::string, std::string> &vars, const std
|
||||||
input.emplace_back(begin, pos);
|
input.emplace_back(begin, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void list_prep_cmd_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, std::vector<prep_cmd_t> &input) {
|
void list_prep_cmd_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, std::vector<prep_cmd_t> &input) {
|
||||||
std::string string;
|
std::string string;
|
||||||
string_f(vars, name, string);
|
string_f(vars, name, string);
|
||||||
|
|
||||||
std::stringstream jsonStream;
|
std::stringstream jsonStream;
|
||||||
|
|
||||||
|
// check if string is empty, i.e. when the value doesn't exist in the config file
|
||||||
|
if(string.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to add a wrapping object to make it valid JSON, otherwise ptree cannot parse it.
|
// We need to add a wrapping object to make it valid JSON, otherwise ptree cannot parse it.
|
||||||
jsonStream << "{\"prep_cmd\":" << string << "}";
|
jsonStream << "{\"prep_cmd\":" << string << "}";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue