summaryrefslogtreecommitdiff
path: root/misc/scripts
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-01-13 00:29:17 +0100
committerGitHub <noreply@github.com>2023-01-13 00:29:17 +0100
commit7067c64bcfc4bbb4c9cbd191ce4b47c2ff13701c (patch)
tree6086ee5ac43e3c559bd10bb2a1949f45cd9c6f06 /misc/scripts
parent8bd8c4edbc6ff6af0718f3f4716df1f0724b9e38 (diff)
parent06450bfb0fb2b4aad04611bd9044ad93e407c504 (diff)
Merge pull request #71297 from aaronfranke/file-format
Fix file formatting script dependencies and cleanup
Diffstat (limited to 'misc/scripts')
-rwxr-xr-xmisc/scripts/file_format.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh
index a2f33692f9..3ff5798e22 100755
--- a/misc/scripts/file_format.sh
+++ b/misc/scripts/file_format.sh
@@ -4,9 +4,9 @@
# This is supplementary to clang_format.sh and black_format.sh, but should be
# run before them.
-# We need dos2unix and recode.
-if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then
- printf "Install 'dos2unix' and 'recode' to use this script.\n"
+# We need dos2unix and isutf8.
+if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v isutf8)" ]; then
+ printf "Install 'dos2unix' and 'isutf8' (moreutils package) to use this script.\n"
fi
set -uo pipefail
@@ -53,22 +53,24 @@ done
diff=$(git diff --color)
-# If no UTF-8 violations were collected and no diff has been
-# generated all is OK, clean up, and exit.
if [ ! -s utf8-validation.txt ] && [ -z "$diff" ] ; then
+ # If no UTF-8 violations were collected (the file is empty) and
+ # no diff has been generated all is OK, clean up, and exit.
printf "Files in this commit comply with the formatting rules.\n"
- rm -f utf8-violations.txt
+ rm -f utf8-validation.txt
exit 0
fi
-# Violations detected, notify the user, clean up, and exit.
if [ -s utf8-validation.txt ]
then
+ # If the file has content and is not empty, violations
+ # detected, notify the user, clean up, and exit.
printf "\n*** The following files contain invalid UTF-8 character sequences:\n\n"
cat utf8-validation.txt
- rm -f utf8-validation.txt
fi
+rm -f utf8-validation.txt
+
if [ ! -z "$diff" ]
then
printf "\n*** The following differences were found between the code "