[pretty] fix script/clang-format (#8814)

`script/clang-format` is supposed to add an EOF newline for every file
passed in as an argument. However, the script only processed the first
file. This can cause `script/make-pretty check` to fail even after
`script/make-pretty clang`.
This commit is contained in:
whd
2023-03-02 10:10:28 +08:00
committed by GitHub
parent 091f68ed70
commit a3d1aa7309

View File

@ -57,18 +57,23 @@ clang-format "$@" || die
# ensure EOF newline
REPLACE=no
FILES=()
for arg; do
case $arg in
-i)
REPLACE=yes
;;
-*) ;;
*)
FILES+=("$arg")
;;
esac
done
file=$arg
[ $REPLACE != yes ] || {
[ -n "$(tail -c1 "$file")" ] && echo >>"$file"
for file in "${FILES[@]}"; do
[ -n "$(tail -c1 "$file")" ] && echo >>"$file"
done
}
exit 0