From a3d1aa7309782af1b9cc7ff5585ea32466c0c18e Mon Sep 17 00:00:00 2001 From: whd <7058128+superwhd@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:10:28 +0800 Subject: [PATCH] [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`. --- script/clang-format | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/script/clang-format b/script/clang-format index 1d58a925c..e31466d22 100755 --- a/script/clang-format +++ b/script/clang-format @@ -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