lint!
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 31s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m27s

This commit is contained in:
j
2025-12-27 23:29:50 +13:00
parent 0257a9c75c
commit 8021e3f57b
4 changed files with 440 additions and 0 deletions

View File

@@ -701,6 +701,44 @@
return true;
}
bool template_manager::check_template_shell_scripts_syntax(const std::string &template_path)
{
if (template_path.empty() || !std::filesystem::exists(template_path))
return false;
bool all_passed = true;
// Find all .sh files
for (const auto& entry : std::filesystem::recursive_directory_iterator(template_path)) {
if (entry.is_regular_file() && entry.path().extension() == ".sh") {
std::string script_path = entry.path().string();
std::string command = "bash -n " + script_path + " 2>&1";
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
error << "Failed to run bash -n on " << entry.path().filename() << std::endl;
all_passed = false;
continue;
}
char buffer[256];
std::string output;
while (fgets(buffer, sizeof(buffer), pipe) != nullptr) {
output += buffer;
}
int result = pclose(pipe);
if (result != 0 || !output.empty()) {
error << "Syntax error in " << entry.path().filename() << ":" << std::endl;
error << output << std::endl;
all_passed = false;
}
}
}
return all_passed;
}
template_manager & gTemplateManager()
{
static template_manager instance;