From d8466672d173ea4ae2a24f1da71bb9e54b563488 Mon Sep 17 00:00:00 2001 From: Droid Date: Sat, 5 Sep 2026 12:48:58 +0000 Subject: [PATCH] fix(scripts): pass --source to chezmoi execute-template render_template() in scripts/lint-shell-templates.sh rendered templates against the default chezmoi source directory, so include directives like the one in the Rectangle reload script failed on runners where ~/.local/share/chezmoi is not the repo root. Add --source "$repo_root" so chezmoi execute-template resolves includes relative to the repository being linted. While editing this script, also split the local rendered=... declaration in lint_zsh_template() to avoid masking the return value of the command substitution (shellcheck SC2155). Closes #169 Fixes #167 --- scripts/lint-shell-templates.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/lint-shell-templates.sh b/scripts/lint-shell-templates.sh index 8c87606..a616618 100755 --- a/scripts/lint-shell-templates.sh +++ b/scripts/lint-shell-templates.sh @@ -50,9 +50,11 @@ EOF chezmoi_config="$tmpdir/chezmoi.toml" # Render a chezmoi template to stdout using the non-interactive config. +# --source "$repo_root" ensures include directives resolve against the +# repository's source tree rather than the default chezmoi source directory. render_template() { local tmpl="$1" - chezmoi execute-template --config "$chezmoi_config" < "$tmpl" + chezmoi execute-template --config "$chezmoi_config" --source "$repo_root" < "$tmpl" } # Lint a rendered bash template with shellcheck. @@ -72,7 +74,8 @@ lint_sh_template() { # Lint a rendered zsh template with zsh -n (shellcheck does not support zsh). lint_zsh_template() { local tmpl="$1" - local rendered="$tmpdir/$(basename "$tmpl" .tmpl)" + local rendered + rendered="$tmpdir/$(basename "$tmpl" .tmpl)" echo "=== $tmpl (zsh) ===" render_template "$tmpl" > "$rendered" if command -v zsh >/dev/null 2>&1; then