From 014ca7e8a16e3882cf2e4b7875860765eb1a6034 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 27 Mar 2023 16:46:25 -0400 Subject: [PATCH] commands: fix prep commands when empty (#1083) --- src/config.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/config.cpp b/src/config.cpp index 4a454b41..0aecc3ca 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -762,12 +762,18 @@ void list_string_f(std::unordered_map &vars, const std input.emplace_back(begin, pos); } } + void list_prep_cmd_f(std::unordered_map &vars, const std::string &name, std::vector &input) { std::string string; string_f(vars, name, string); 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. jsonStream << "{\"prep_cmd\":" << string << "}";