print-non-newline.sh 766 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. #
  6. # The purpose of this file is to find the files that do not end with a
  7. # newline. Some compilers fail if the source files do not end with a
  8. # newline.
  9. #
  10. #
  11. test_file=newline_test
  12. test_dummy=newline_testee
  13. inlist="$*"
  14. broken_list=
  15. if test "$inlist" = ""; then
  16. echo "Usage: $0 *.c *.cpp";
  17. exit 0;
  18. fi
  19. echo "" > $test_file
  20. for f in $inlist; do
  21. if test -f $f; then
  22. tail -c 1 $f > $test_dummy
  23. if ! `cmp -s $test_file $test_dummy`; then
  24. broken_list="$broken_list $f"
  25. fi
  26. fi
  27. done
  28. rm -f $test_file $test_dummy
  29. echo $broken_list