From 68aaa8a18f394b0da00fa0660c251aee07114074 Mon Sep 17 00:00:00 2001 From: Jensfrank Date: Thu, 27 Jun 2024 12:10:51 +0800 Subject: [PATCH] Update nodeloc_vps_autotest_ip.sh --- nodeloc_vps_autotest_ip.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nodeloc_vps_autotest_ip.sh b/nodeloc_vps_autotest_ip.sh index fc25ea9..6d205ed 100644 --- a/nodeloc_vps_autotest_ip.sh +++ b/nodeloc_vps_autotest_ip.sh @@ -158,22 +158,29 @@ run_all_tests() { # 格式化结果为 Markdown format_results() { -result="[tabs] + # 转义特殊字符,但保留颜色代码 + escaped_result=$(echo "$ip_quality_result" | sed 's/\\/\\\\/g; s/`/\\`/g; s/\$/\\$/g; s/\*/\\*/g; s/_/\\_/g') + + result="[tabs] [tab=\"IP质量\"] -\`\`\` -$ip_quality_result +\`\`\`ansi +$escaped_result \`\`\` [/tab] [/tabs] " - echo "$result" | iconv -f UTF-8 -t UTF-8//IGNORE > results.md + echo "$result" > results.md echo -e "${GREEN}结果已保存到 results.md 文件中。${NC}" } # 主函数 main() { - install_dependencies - show_welcome + if type install_dependencies &>/dev/null; then + install_dependencies + fi + if type show_welcome &>/dev/null; then + show_welcome + fi run_all_tests echo -e "${GREEN}所有测试完成。结果已保存到 results.md 文件中。${NC}" echo "最终结果文件内容:" >&2