#!/bin/bash# Template generated by https://github.com/coreos/repo-templates; do not edit downstreamset -euo pipefailmain() {local files_with_whitespace=""local files_with_missing_empty_line_at_eof=""while IFS= read -r -d '' f; doecho "[+] Checking ${f}"# Looking for whitespace at end of lineif grep -Eq " +$" "${f}"; then# List of files to ignoreif \[[ "${f}" == "./live/isolinux/boot.msg" ]] \; thenecho "[+] Checking ${f}: Ignoring whitespace at end of line"elseecho "[+] Checking ${f}: Found whitespace at end of line"files_with_whitespace+=" ${f}"fifi# Looking for missing empty line at end of fileif [[ -n $(tail -c 1 "${f}") ]]; then# List of files to ignoreif \[[ "${f}" == "./tests/kola/ignition/resource/authenticated-gs/data/expected/"* ]] ||\[[ "${f}" == "./tests/kola/ignition/resource/authenticated-s3/data/expected/"* ]] ||\[[ "${f}" == "./tests/kola/ignition/resource/remote/data/expected/"* ]] \; thenecho "[+] Checking ${f}: Ignoring missing empty line at end of file"elseecho "[+] Checking ${f}: Missing empty line at end of file"files_with_missing_empty_line_at_eof+=" ${f}"fifidone< <(find . -path "./.git" -prune -o -type f -print0)echo ""if [[ -n "${files_with_whitespace}" ]]; thenecho "[+] Found files with whitespace at the end of line"echo "${files_with_whitespace}" | tr ' ' '\n'elseecho "[+] No files with whitespace at the end of line"fiecho ""if [[ -n "${files_with_missing_empty_line_at_eof}" ]]; thenecho "[+] Found files with missing empty line at end of file"echo "${files_with_missing_empty_line_at_eof}" | tr ' ' '\n'elseecho "[+] No files with missing empty line at end of file"fiif [[ -n "${files_with_whitespace}" ]] || [[ -n "${files_with_missing_empty_line_at_eof}" ]]; thenexit 1fiexit 0}main "${@}"