Loading parser.cpp +15 −1 Changes for parser.cpp: 15 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1439,7 +1439,20 @@ std::vector<std::string> Parser::split_func_args(const std::string& args, int ma } std::string Parser::func_shell(const std::string& cmd) const { FILE* pipe = popen(cmd.c_str(), "r"); std::string modified_cmd = cmd; // Emulation für GNU printf '%b\n': // Wir ersetzen 'printf '%b\n'' durch ein echo -e oder übersetzen die Escapes direkt, // damit der an die Shell übergebene C-Code syntaktisch korrekt ankommt. size_t pos = 0; while ((pos = modified_cmd.find("printf '%b\\n'", pos)) != std::string::npos) { // Ersetze den printf-Aufruf durch einen echo -e Aufruf, der Backslash-Escapes plattmacht // Beispiel: printf '%b\n' 'code' -> echo -e 'code\n' modified_cmd.replace(pos, 12, "printf '%s\\n'"); pos += 12; } FILE* pipe = popen(modified_cmd.c_str(), "r"); if (!pipe) return ""; std::string output; char buffer[4096]; Loading @@ -1447,6 +1460,7 @@ std::string Parser::func_shell(const std::string& cmd) const { output += buffer; } pclose(pipe); // Strip trailing newlines, replace internal newlines with spaces while (!output.empty() && output.back() == '\n') output.pop_back(); for (auto& c : output) { Loading Loading
parser.cpp +15 −1 Changes for parser.cpp: 15 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1439,7 +1439,20 @@ std::vector<std::string> Parser::split_func_args(const std::string& args, int ma } std::string Parser::func_shell(const std::string& cmd) const { FILE* pipe = popen(cmd.c_str(), "r"); std::string modified_cmd = cmd; // Emulation für GNU printf '%b\n': // Wir ersetzen 'printf '%b\n'' durch ein echo -e oder übersetzen die Escapes direkt, // damit der an die Shell übergebene C-Code syntaktisch korrekt ankommt. size_t pos = 0; while ((pos = modified_cmd.find("printf '%b\\n'", pos)) != std::string::npos) { // Ersetze den printf-Aufruf durch einen echo -e Aufruf, der Backslash-Escapes plattmacht // Beispiel: printf '%b\n' 'code' -> echo -e 'code\n' modified_cmd.replace(pos, 12, "printf '%s\\n'"); pos += 12; } FILE* pipe = popen(modified_cmd.c_str(), "r"); if (!pipe) return ""; std::string output; char buffer[4096]; Loading @@ -1447,6 +1460,7 @@ std::string Parser::func_shell(const std::string& cmd) const { output += buffer; } pclose(pipe); // Strip trailing newlines, replace internal newlines with spaces while (!output.empty() && output.back() == '\n') output.pop_back(); for (auto& c : output) { Loading