improve chk_tree and trailblank

The chk_tree will check for files in distlist that
would otherwise be ignored by trailblank or that
are used, by convention, as tempory / test files.

Fixed a shellcheck nit in trailblank.
This commit is contained in:
Landon Curt Noll
2023-10-06 22:25:00 -07:00
parent 0e6016f429
commit 01f0605055
2 changed files with 28 additions and 2 deletions

View File

@@ -260,6 +260,9 @@ fi
# We ignore .*.swp files as they are a result of vim sessions.
# We ignore *.out files as they are used to collect information.
# We ignore single letter files as they are used for temporary files.
# We ignore files containing the any of the following in any letter case:
#
# foo bar baz curds whey rmme
#
declare -a FINDFILE
mapfile -t FINDFILE < <(find . -type f \
@@ -267,7 +270,9 @@ mapfile -t FINDFILE < <(find . -type f \
! -path './.git/*' ! -name .git \
! -path './.github/*' ! -name .github \
! -name 'CODE_OF_CONDUCT.md' ! -name 'CONTRIBUTING.md' ! -name '.gitignore' ! -name 'SECURITY.md' \
! -name '*.swp' ! -name '*.out' ! -name '?' |
! -name '*.swp' ! -name '?' ! -iname '*.out*' \
! -iname '*foo*' ! -iname '*bar*' ! -iname '*baz*' \
! -iname '*curds*' ! -iname '*whey*' ! -iname '*rmmee' -print |
sed -e 's/^\.\///' | sort -u)
if [[ ${#FINDFILE[@]} -le 0 ]]; then
echo "$0: ERROR: find file is empty" 1>&2
@@ -316,6 +321,27 @@ if [[ ${#UNKNOWN_FILE[@]} -ne 0 ]]; then
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# Look for a find in distlist that would otherwise be ignored
#
# We ignore for trailblank and FINDFILE, filenames with a single letter, and files
# that end in .out, and files containing the any of the following
# in any letter case:
#
# foo bar baz curds whey rmme
#
# So we will object is any distlist file is one of these ignored filenames.
#
INVALID_DISTLIST=$(printf '%s\n' "${DISTLIST[@]}" | \
tr '[:upper:]' '[:lower:]' | \
sed -n -e '/^.$/p' -e '/.*foo.*/p' -e '/.*bar.*/p' -e '/.*baz.*/p' \
-e '/.*curds.*/p' -e '/.*whey.*/p' -e '/.*rmme.*/p' |
tr '\n' ' ')
if [[ -n $INVALID_DISTLIST ]]; then
echo "$0: ERROR: distlist contains invalid filename(s): $INVALID_DISTLIST" 1>&2
EXIT_CODE=28
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# All Done!!! -- Jessica Noll, Age 2
#
if [[ $EXIT_CODE -ne 0 ]]; then

View File

@@ -212,7 +212,7 @@ if [[ -n $BACKUP_MAKEILES ]]; then
echo
echo "# You need execute the following to remove backup Makefiles:"
echo
echo "$BACKUP_MAKEILES" | while read file; do
echo "$BACKUP_MAKEILES" | while read -r file; do
echo "rm -f $file"
done
EXIT_CODE=7