Fix check_trailing_newlines bug

pull/24520/head
Esun Kim 4 years ago
parent fb454347c7
commit 48a7fe7752
  1. 7
      tools/distrib/check_trailing_newlines.sh
  2. 2
      tools/distrib/sanitize.sh

@ -29,7 +29,7 @@ function find_without_newline() {
if [[ ! -z $f ]]; then
if [[ $(tail -c 1 "$f") != $NEWLINE ]]; then
echo "Error: file '$f' is missing a trailing newline character."
if $2; then # fix
if $1; then # fix
sed -i -e '$a\' $f
echo 'Fixed!'
fi
@ -39,11 +39,12 @@ function find_without_newline() {
}
if [[ $# == 1 && $1 == '--fix' ]]; then
ERRORS=$(find_without_newline true)
FIX=true
else
ERRORS=$(find_without_newline false)
FIX=false
fi
ERRORS=$(find_without_newline $FIX)
if [[ "$ERRORS" != '' ]]; then
echo "$ERRORS"
if ! $FIX; then

@ -20,5 +20,5 @@ cd $(dirname $0)/../..
tools/buildgen/generate_projects.sh
tools/distrib/clang_format_code.sh
tools/distrib/check_copyright.py
tools/distrib/check_trailing_newlines.sh
tools/distrib/check_trailing_newlines.sh --fix

Loading…
Cancel
Save