Skip to content

Commit ba05188

Browse files
author
Kacper Sawicki
authored
ci: add lint check to prevent single quotes in bootstrap scripts (coder#22664)
## Problem Bootstrap scripts under `provisionersdk/scripts/` are inlined into templates via `sh -c '${init_script}'`. Any single quote (apostrophe) in these `.sh` files silently breaks the shell quoting, causing the agent to never start — with near-invisible error output. ## Changes - **`scripts/check_bootstrap_quotes.sh`** — new lint script that scans all `.sh` files under `provisionersdk/scripts/` for single quotes and fails with a clear error if any are found. Only checks shell scripts (not `.ps1`, which legitimately uses single quotes). - **`Makefile`** — added `lint/bootstrap` target wired into the `lint` dependency list. Fixes coder#22062
1 parent 71ac484 commit ba05188

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ endif
606606
# GitHub Actions linters are run in a separate CI job (lint-actions) that only
607607
# triggers when workflow files change, so we skip them here when CI=true.
608608
LINT_ACTIONS_TARGETS := $(if $(CI),,lint/actions/actionlint)
609-
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/check-scopes lint/migrations $(LINT_ACTIONS_TARGETS)
609+
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/check-scopes lint/migrations lint/bootstrap $(LINT_ACTIONS_TARGETS)
610610
.PHONY: lint
611611

612612
lint/site-icons:
@@ -636,6 +636,11 @@ lint/shellcheck: $(SHELL_SRC_FILES)
636636
shellcheck --external-sources $(SHELL_SRC_FILES)
637637
.PHONY: lint/shellcheck
638638

639+
lint/bootstrap:
640+
bash scripts/check_bootstrap_quotes.sh
641+
.PHONY: lint/bootstrap
642+
643+
639644
lint/helm:
640645
cd helm/
641646
make lint

scripts/check_bootstrap_quotes.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
# shellcheck source=scripts/lib.sh
4+
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
5+
cdroot
6+
7+
echo "--- check bootstrap scripts for single quotes"
8+
9+
files=$(find provisionersdk/scripts -type f -name '*.sh')
10+
found=0
11+
for f in $files; do
12+
if grep -n "'" "$f"; then
13+
echo "ERROR: $f contains single quotes (apostrophes)."
14+
echo " Bootstrap scripts are inlined via sh -c '...' in templates."
15+
echo " Single quotes break this quoting. Use alternative phrasing."
16+
found=1
17+
fi
18+
done
19+
20+
if [ "$found" -ne 0 ]; then
21+
exit 1
22+
fi
23+
24+
echo "OK: no single quotes found in bootstrap scripts."

0 commit comments

Comments
 (0)