修复bug:脚本检查系统环境时如果操作系统是Darwin,检查内存使用情况输出为空,原因是正则表达式有问题

This commit is contained in:
fuyaozong
2025-11-13 09:32:54 +08:00
committed by lyingbug
parent ef69e2aed5
commit a625eff525

View File

@@ -538,7 +538,7 @@ check_environment() {
# 检查内存 # 检查内存
log_info "检查内存使用情况..." log_info "检查内存使用情况..."
if [ "$OS" = "Darwin" ]; then if [ "$OS" = "Darwin" ]; then
vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; /Pages free: (\d+)/ and print "Free Memory: ", $1 * $size / 1048576, " MB\n"' vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; /Pages free:\s*(\d+)/ and print "Free Memory: ", $1 * $size / 1048576, " MB\n"'
else else
free -h | grep -E "(total|Mem:)" free -h | grep -E "(total|Mem:)"
fi fi