You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
481 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# 新增自动修复功能
find . -type f -not -path './.git/*' -exec sh -c '
file="$1"
if file -b --mime-encoding "$file" | grep -qv binary; then
# 自动修复CRLF
if grep -qP '\r$' "$file"; then
sed -i 's/\r$//' "$file"
echo "🛠️ 已修复 $file"
fi
# 验证UTF-8编码
if ! iconv -f UTF-8 -t UTF-8 "$file" &>/dev/null; then
echo "❌ $file 存在非法UTF-8字符需手动处理"
exit 1
fi
fi
' sh {} \;