fix(validate): only judge configs/ files that are actually sourced

validateSystemConfiguration ran `bash -n` over every file two levels deep
under configs/, so a data file in a directory with no .category marker was
reported as "does not parse as shell" — a configuration problem about a file
nothing executes, pointing whoever read it at the wrong thing.

Apply the same rule the loader uses: a file in a SUBDIRECTORY is judged only
when that directory carries .category. Files directly in configs/ are checked
as before.

No behaviour change for any real config — every category (webui, general,
security, backup, network) carries the marker.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-29 02:35:19 +01:00
parent b0a00649f7
commit 1ed42c7645

View File

@ -299,6 +299,16 @@ validateSystemConfiguration()
local f
while IFS= read -r f; do
[[ -f "$f" ]] || continue
# Only judge what actually gets sourced. sourceScanFiles sources a file in
# a SUBDIRECTORY only when that directory carries .category, so an unmarked
# directory holds ordinary data — and "does not parse as shell" is a
# meaningless complaint about a file nothing executes. Reporting it as a
# config problem sends someone fixing the wrong thing. Depth-1 files
# (directly in configs/) are checked as before, matching the loader.
local parent_dir="${f%/*}"
if [[ "$parent_dir" != "${configs_dir%/}" && ! -f "$parent_dir/.category" ]]; then
continue
fi
bash -n "$f" 2>/dev/null || _lpvFail "$(basename "$f") does not parse as shell."
local dup
dup=$(grep -oE '^CFG_[A-Z0-9_]+=' "$f" | sort | uniq -d | tr -d '=')