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

5 months ago
#!/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 {} \;