Skip to content

Commit

Permalink
Make lint script use sh
Browse files Browse the repository at this point in the history
  • Loading branch information
lavoiesl committed May 22, 2019
1 parent f0bc3d6 commit 3d2f178
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions bin/lint-fix.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if [ ! -f ".clang-format" ]; then
echo ".clang-format file not found!"
Expand All @@ -8,9 +8,12 @@ fi
changed=0

for file in $(find . -name '*.c' -o -name '*.h'); do
formatted="$(clang-format -style=file "${file}")"
if ! echo "${formatted}" | cmp - "${file}" >/dev/null; then
echo "${formatted}" > "${file}"
tmp="$(mktemp)"
clang-format -style=file "${file}" > "${tmp}"
if cmp "${tmp}" "${file}" >/dev/null; then
rm "${tmp}"
else
mv "${tmp}" "${file}"
echo "Formatted ${file}"
changed=1
fi
Expand Down
7 changes: 5 additions & 2 deletions bin/lint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if [ ! -f ".clang-format" ]; then
echo ".clang-format file not found!"
Expand All @@ -8,10 +8,13 @@ fi
failures=0
for file in $(find . -name '*.c' -o -name '*.h'); do
echo "Checking ${file}"
diff -u <(clang-format -style=file "${file}") "${file}"
tmp="$(mktemp)"
clang-format -style=file "${file}" > "${tmp}"
diff -u "${tmp}" "${file}"
if [[ $? -gt 0 ]]; then
failures=$((failures + 1))
fi
rm "${tmp}"
done

[[ "${failures}" -eq 0 ]] || exit 1

0 comments on commit 3d2f178

Please sign in to comment.