Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
- Replace raw echo with output helpers in db/createmssqldb
- Replace raw echo with standard output helpers (die/info/success) in db/create-deploy-script
- git/fetch: Unset core.hookspath for each repo during fetch so that globally-configured hook paths do not persist on individual repos
- check: use mapfile array for file collection to handle filenames containing spaces correctly
- check: guard against empty file list before checking — prevents false-positive success when no scripts are found
### Changed
- Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows
- Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal
- Replace raw echo with output helpers (die, info, success) in git/missing-release-branches
- git/make-preview: replaced raw echo with die/info/success output helpers
- Replaced raw echo with output helpers (die/info/success) in git/clean-all
- GEOIP - Updated GEOIP DB from MaxMind (2026-06-24)
- check: replaced raw echo-based output with standard die, info, and success helpers
### Deprecated
### Removed
- db/sqlcompare script deleted — no longer in use
Expand Down
66 changes: 38 additions & 28 deletions check
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
#! /bin/bash

die() {
echo "$@"
if [ -t 2 ]; then
printf '\n\033[31m✗\033[0m %s\n' "$*" >&2
else
printf '\n✗ %s\n' "$*" >&2
fi
exit 1
}

testing() {
echo " + $*"
}

hint() {
echo " ? CHECK: $*"
success() {
Comment thread
credfeto marked this conversation as resolved.
if [ -t 1 ]; then
printf '\n\033[32m✓\033[0m %s\n' "$*"
else
printf '\n✓ %s\n' "$*"
fi
}

fail() {
echo " - ERROR: $*"
exit 1

info() {
if [ -t 1 ]; then
printf '\n\033[32m→\033[0m %s\n' "$*"
else
printf '\n→ %s\n' "$*"
fi
}


Expand All @@ -39,7 +45,7 @@ excluded() {
}

# Find all the script files both executable and ones with shebang
FILES=$({ \
mapfile -t FILES < <({ \
find "$BASEDIR" -not -path '*/.*' -type f -executable -print || die "Search: find"
while IFS= read -r SHEBANG_FILE; do
IFS= read -r FIRST_LINE < "$SHEBANG_FILE" || continue
Expand All @@ -52,47 +58,51 @@ FILES=$({ \
done < <(find "$BASEDIR" -not -path '*/.*' -type f -print) || die "Search: Shebang"
} | sort | uniq)

echo "Testing:"
for FILE in $FILES; do
echo "* $FILE"
testing "Executable"
[ "${#FILES[@]}" -gt 0 ] || die "No script files found in ${BASEDIR}"

info "Testing:"
for FILE in "${FILES[@]}"; do
info "* $FILE"
Comment thread
credfeto marked this conversation as resolved.
info "Executable"
if [ ! -x "$FILE" ]; then
fail "Not Executable"
die "Not Executable: ${FILE}"
fi

testing "Shebang"
info "Shebang"
FIRST_LINE=$(head -1 "$FILE")
if [[ $FIRST_LINE =~ $REGEX_SHEBANG ]]; then
SHEBANG_EXEC="${BASH_REMATCH[1]}"
SHELL=
if [ "$SHEBANG_EXEC" = "/bin/bash" ]; then
SHELL="bash"
bash -n -u "$FILE" || fail "$SHELL: Invalid Script"
sh -n "$FILE" > /dev/null 2>&1 && hint "Could be run in bash?"
bash -n -u "$FILE" || die "$SHELL: Invalid Script: ${FILE}"
sh -n "$FILE" > /dev/null 2>&1 && info "Hint: Could be run in sh?"
elif [ "$SHEBANG_EXEC" = "/usr/bin/env bash" ]; then
SHELL="bash"
bash -n -u "$FILE" || fail "$SHELL: Invalid Script"
sh -n "$FILE" > /dev/null 2>&1 && hint "Could be run in bash?"
bash -n -u "$FILE" || die "$SHELL: Invalid Script: ${FILE}"
sh -n "$FILE" > /dev/null 2>&1 && info "Hint: Could be run in sh?"
elif [ "$SHEBANG_EXEC" = "/bin/sh" ]; then
SHELL="sh"
sh -n "$FILE" || fail "$SHELL: Invalid Script"
sh -n "$FILE" || die "$SHELL: Invalid Script: ${FILE}"
elif [ "$SHEBANG_EXEC" = "/usr/bin/env sh" ]; then
SHELL="sh"
sh -n "$FILE" || fail "$SHELL: Invalid Script"
sh -n "$FILE" || die "$SHELL: Invalid Script: ${FILE}"
else
fail "Unknown Shell: $SHEBANG_EXEC"
die "Unknown Shell: $SHEBANG_EXEC in ${FILE}"
fi


else
fail "No Shebang: $FIRST_LINE"
die "No Shebang: $FIRST_LINE in ${FILE}"
fi

## Run Shellcheck on the file
if [ "$(excluded "$FILE")" = "1" ]; then
hint "Excluded from shellcheck"
info "Excluded from shellcheck"
else
shellcheck "$FILE" || fail "Shellcheck"
shellcheck "$FILE" || die "Shellcheck: ${FILE}"
fi

done

success "All checks passed"
Comment thread
credfeto marked this conversation as resolved.
Loading