summaryrefslogtreecommitdiff
path: root/misc/scripts/file_format.sh
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2023-04-26 17:57:45 +0200
committerGitHub <noreply@github.com>2023-04-26 17:57:45 +0200
commitba004ea1c3b00c5516548edde7bdfe2d72d51ea1 (patch)
tree534f23706b47017760b8d5e9395b00ef3ebd385a /misc/scripts/file_format.sh
parentd78691d44fe6e4f38dce3a89164cdae688772031 (diff)
parente7f4af091331ef10dd2088d82bc552a097d3d4ce (diff)
Merge pull request #76476 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 3rd batch
Diffstat (limited to 'misc/scripts/file_format.sh')
-rwxr-xr-xmisc/scripts/file_format.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/misc/scripts/file_format.sh b/misc/scripts/file_format.sh
index f394c4ad3f..94a3affbd7 100755
--- a/misc/scripts/file_format.sh
+++ b/misc/scripts/file_format.sh
@@ -7,14 +7,20 @@
# 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"
+ exit 1
fi
set -uo pipefail
-IFS=$'\n\t'
-# Loops through all text files tracked by Git.
-git grep -zIl '' |
-while IFS= read -rd '' f; do
+if [ $# -eq 0 ]; then
+ # Loop through all code files tracked by Git.
+ mapfile -d '' files < <(git grep -zIl '')
+else
+ # $1 should be a file listing file paths to process. Used in CI.
+ mapfile -d ' ' < <(cat "$1")
+fi
+
+for f in "${files[@]}"; do
# Exclude some types of files.
if [[ "$f" == *"csproj" ]]; then
continue