lint!
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user