Skip to content

ci(docker): add shellcheck shell=sh directive to main-wrapper.sh - #33063

Merged
benbarclay merged 1 commit into
mainfrom
fix-main-wrapper-shellcheck
May 27, 2026
Merged

ci(docker): add shellcheck shell=sh directive to main-wrapper.sh#33063
benbarclay merged 1 commit into
mainfrom
fix-main-wrapper-shellcheck

Conversation

@benbarclay

Copy link
Copy Markdown
Collaborator

Problem

The Docker / shell lint CI job currently fails on every PR that touches docker/. The actual error:

docker/main-wrapper.sh:1:1: error: This shebang was unrecognized.
  ShellCheck only supports sh/bash/dash/ksh/'busybox sh'.
  Add a 'shell' directive to specify. [SC1008]

shellcheck doesn't recognize the s6-overlay #!/command/with-contenv sh shebang and treats it as a hard error (the workflow runs with --severity=error but SC1008 fires at that severity anyway).

How we got here

PR #32412 (commit 29c71e9) correctly changed the shebang from #!/bin/sh#!/command/with-contenv sh to fix env-propagation through s6-overlay's /init PID 1. That change is right.

The # shellcheck shell=sh directive — already present on the sibling docker/cont-init.d/02-reconcile-profiles and 015-supervise-perms scripts which use the same shebang — was missed when main-wrapper.sh adopted it.

Fix

Add # shellcheck shell=sh as the second line of docker/main-wrapper.sh. Same pattern as the working sibling scripts.

 #!/command/with-contenv sh
+# shellcheck shell=sh
 # /opt/hermes/docker/main-wrapper.sh — wraps the container's CMD with

The directive is a comment; script behavior is unchanged.

Validation

Local reproduction of the CI failure (using koalaman/shellcheck:stable, the same image ludeeus/action-shellcheck shells out to):

docker run --rm -v "$PWD:/mnt" -w /mnt koalaman/shellcheck:stable \
  --severity=error --format=gcc docker/main-wrapper.sh
  • Before: docker/main-wrapper.sh:1:1: error: [SC1008] (rc=1)
  • After: (no output) (rc=0)

Parser sanity-check (sh -n / bash -n) passes on both before and after — the directive doesn't change script semantics.

After this lands

The Docker / shell lint job goes green for every PR touching docker/. Currently visible failures on at least #33060 will clear on rebase.

shellcheck doesn't recognize the s6-overlay `#!/command/with-contenv sh`
shebang and aborts with SC1008 ("This shebang was unrecognized. ShellCheck
only supports sh/bash/dash/ksh/'busybox sh'. Add a 'shell' directive to
specify."). The error fires at --severity=error too, so it fails the
"Docker / shell lint" CI job on every PR that touches docker/.

Add the canonical `# shellcheck shell=sh` directive — same fix already
applied to the sibling cont-init.d scripts (`02-reconcile-profiles` and
`015-supervise-perms`) when they adopted the with-contenv shebang.

The shebang was changed from `#!/bin/sh` → `#!/command/with-contenv sh`
in PR #32412 (commit 29c71e9) to fix env-propagation through s6's PID 1.
The shellcheck-directive line was missed in that PR; this patches it.

Reproduces locally:
  docker run --rm -v "$PWD:/mnt" -w /mnt koalaman/shellcheck:stable \
    --severity=error --format=gcc docker/main-wrapper.sh

Before:  docker/main-wrapper.sh:1:1: error: [SC1008]  (rc=1)
After:   (no output)                                   (rc=0)

Script behavior is unchanged — the directive is a comment, and `sh -n`
/ `bash -n` parse the file cleanly either way.
@benbarclay benbarclay added the area/docker Docker image, Compose, packaging label May 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix-main-wrapper-shellcheck vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9400 on HEAD, 9400 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4973 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have labels May 27, 2026
@benbarclay
benbarclay merged commit c3bdb2a into main May 27, 2026
25 checks passed
@benbarclay
benbarclay deleted the fix-main-wrapper-shellcheck branch May 27, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants