PX4-Autopilot/Tools/astyle/check_newlines.sh
Matthias Grob 2bc04f91f8 docs: fix all end of file newlines
Note: Some files are autogenerated and I did not yet
go through each source of generation to fix it there.
Instead I adjusted the filter to only exclude those
such that we can fix things in steps.
2025-06-26 11:03:23 -07:00

20 lines
764 B
Bash
Executable File

#!/usr/bin/env bash
return_value=0
# Check if there are files checked in that don't end in a newline (POSIX requirement)
git grep --cached -Il '' -- ':!docs/public/' ':!docs/ko/' ':!docs/uk/' ':!docs/zh/' | xargs -L1 bash -c 'if test "$(tail -c 1 "$0")"; then echo "No new line at end of $0"; exit 1; fi'
if [ $? -ne 0 ]; then
return_value=1
fi
# Check if there are files checked in that have duplicate newlines at the end (fail trailing whitespace checks)
git grep --cached -Il '' -- ':!docs/public/' ':!docs/ko/' ':!docs/uk/' ':!docs/zh/' | xargs -L1 bash -c 'if tail -c 2 "$0" | ( read x && read y && [ x"$x" = x ] && [ x"$y" = x ]); then echo "Multiple newlines at the end of $0"; exit 1; fi'
if [ $? -ne 0 ]; then
return_value=1
fi
exit $return_value