[scripts] apply shfmt changes (#4966)

This commit is contained in:
Jonathan Hui
2020-05-14 14:23:56 -07:00
parent 916023b6e7
commit cb9b353fb3
15 changed files with 221 additions and 194 deletions

View File

@ -29,7 +29,8 @@
CLANG_FORMAT_VERSION="clang-format version 6.0"
die() {
die()
{
echo " *** ERROR: $*"
exit 1
}
@ -38,12 +39,12 @@ die() {
# expand_aliases shell option is set using shopt.
shopt -s expand_aliases
if command -v clang-format-6.0 > /dev/null; then
if command -v clang-format-6.0 >/dev/null; then
alias clang-format=clang-format-6.0
elif command -v clang-format > /dev/null; then
elif command -v clang-format >/dev/null; then
case "$(clang-format --version)" in
"$CLANG_FORMAT_VERSION"*)
;;
"$CLANG_FORMAT_VERSION"*) ;;
*)
die "$(clang-format --version); clang-format 6.0 required"
;;
@ -56,8 +57,7 @@ clang-format "$@" || die
# ensure EOF newline
REPLACE=no
for arg
do
for arg; do
case $arg in
-i)
REPLACE=yes
@ -68,7 +68,7 @@ done
file=$arg
[ $REPLACE != yes ] || {
[ -n "$(tail -c1 "$file")" ] && echo >> "$file"
[ -n "$(tail -c1 "$file")" ] && echo >>"$file"
}
exit 0