Skip to main content

Module validate

Module validate 

Source
Expand description

Pre-flight syntax check for shell-sourced files.

Runs bash -n / zsh -n against each deployed shell source so that syntax errors in aliases.sh, profile.zsh etc. surface at dodot up time instead of silently breaking the user’s next shell startup. The interpreter’s stderr (which carries file: line N: error_message) is preserved verbatim into a sidecar file under the handler datastore so dodot status can show it later (3c).

This module does not invoke the staged file. It only parses it. bash -n / zsh -n are syntax-only — no commands run, no side effects on the user’s environment.

Sidecar layout: <data_dir>/packs/<pack>/shell/.errors/<filename>.err

  • Written on a fresh syntax failure.
  • Removed on a fresh syntax success (so a fix clears the prior error).
  • Untouched when the interpreter is missing (we have no info either way).

Init-script generation already filters non-symlinks, so the .errors subdirectory does not end up sourced at shell startup.

Structs§

NoopSyntaxChecker
SyntaxChecker that always returns SyntaxCheckResult::Ok. Used in tests to keep the validation pass deterministic and hermetic (no real bash/zsh invocations).
ShellValidationFailure
One file that failed pre-flight syntax check.
ShellValidationReport
Summary of one validation pass over the deployed shell sources.
SystemSyntaxChecker
Production SyntaxChecker that spawns real subprocesses.

Enums§

SyntaxCheckResult

Constants§

ERRORS_SUBDIR
Subdirectory (under each pack’s shell handler dir) where sidecar .err files live. Public so 3c (status) can read it back.

Traits§

SyntaxChecker
Run a syntax-only check on a shell file.

Functions§

error_sidecar_path
Path of the sidecar error file for one source.
validate_shell_sources
Iterate every deployed shell source, run a syntax check, and update the per-file sidecar files. Idempotent across runs: a previously failing file that’s been fixed gets its sidecar removed.