diff options
Diffstat (limited to 'dev/tools/check-eof-newline.sh')
| -rwxr-xr-x | dev/tools/check-eof-newline.sh | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/dev/tools/check-eof-newline.sh b/dev/tools/check-eof-newline.sh index c5a654e21d..e244d9ab80 100755 --- a/dev/tools/check-eof-newline.sh +++ b/dev/tools/check-eof-newline.sh @@ -4,8 +4,9 @@ # Detect missing end of file newlines for FILES. # Files are skipped if untracked by git and depending on gitattributes. # With --fix, automatically append a newline. -# Exit status: 1 if any file had a missing newline, 0 otherwise -# (regardless of --fix). +# Exit status: +# Without --fix: 1 if any file had a missing newline, 0 otherwise. +# With --fix: 1 if any non writable file had a missing newline, 0 otherwise. FIX= if [ "$1" = --fix ]; @@ -22,12 +23,18 @@ for f in "$@"; do then if [ -n "$FIX" ]; then - echo >> "$f" - echo "Newline appended to file $f!" + if [ -w "$f" ]; + then + echo >> "$f" + echo "Newline appended to file $f!" + else + echo "File $f is missing a newline and not writable!" + CODE=1 + fi else echo "No newline at end of file $f!" + CODE=1 fi - CODE=1 fi done |
