|
@@ -1,18 +1,21 @@
|
|
-#!/bin/bash
|
|
|
|
|
|
+#!/usr/bin/env bash
|
|
|
|
+
|
|
|
|
+set -uo pipefail
|
|
|
|
+IFS=$'\n\t'
|
|
|
|
|
|
# Loops through all text files tracked by Git.
|
|
# Loops through all text files tracked by Git.
|
|
git grep -zIl '' |
|
|
git grep -zIl '' |
|
|
while IFS= read -rd '' f; do
|
|
while IFS= read -rd '' f; do
|
|
# Exclude csproj and hdr files.
|
|
# Exclude csproj and hdr files.
|
|
- if [[ $f == *"csproj" ]]; then
|
|
|
|
|
|
+ if [[ "$f" == *"csproj" ]]; then
|
|
continue
|
|
continue
|
|
- elif [[ $f == *"hdr" ]]; then
|
|
|
|
|
|
+ elif [[ "$f" == *"hdr" ]]; then
|
|
continue
|
|
continue
|
|
fi
|
|
fi
|
|
# Ensures that files are UTF-8 formatted.
|
|
# Ensures that files are UTF-8 formatted.
|
|
- recode UTF-8 $f 2> /dev/null
|
|
|
|
|
|
+ recode UTF-8 "$f" 2> /dev/null
|
|
# Ensures that files have LF line endings.
|
|
# Ensures that files have LF line endings.
|
|
- dos2unix $f 2> /dev/null
|
|
|
|
|
|
+ dos2unix "$f" 2> /dev/null
|
|
# Ensures that files do not contain a BOM.
|
|
# Ensures that files do not contain a BOM.
|
|
sed -i '1s/^\xEF\xBB\xBF//' "$f"
|
|
sed -i '1s/^\xEF\xBB\xBF//' "$f"
|
|
# Ensures that files end with newline characters.
|
|
# Ensures that files end with newline characters.
|
|
@@ -20,7 +23,7 @@ while IFS= read -rd '' f; do
|
|
done
|
|
done
|
|
|
|
|
|
git diff > patch.patch
|
|
git diff > patch.patch
|
|
-FILESIZE=$(stat -c%s patch.patch)
|
|
|
|
|
|
+FILESIZE="$(stat -c%s patch.patch)"
|
|
MAXSIZE=5
|
|
MAXSIZE=5
|
|
|
|
|
|
# If no patch has been generated all is OK, clean up, and exit.
|
|
# If no patch has been generated all is OK, clean up, and exit.
|