Skip to content

feat: rewrite in bash, keep the zsh plugin as a thin installer - #26

Merged
iamralch merged 4 commits into
mainfrom
feat/bash-rewrite
Nov 19, 2026
Merged

iamralch merged 4 commits into
mainfrom
feat/bash-rewrite

Conversation

@iamralch

@iamralch iamralch commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

The tool is now devcontainer-sh, a bash script at the repo root. devcontainer-sh.plugin.zsh only puts it on PATH and registers the completions, so oh-my-zsh, zinit, antidote and a plain source keep working. The repo is also a GitHub Action and a Nix package.

Why

  • It runs from any shell, including non-interactive CI steps, where a zsh function defined by sourcing a plugin is not available.
  • No zsh dependency on runners.
  • One implementation for dev and CI, so devcontainer-sh exec -- … works the same in both.
  • Plain bats and shellcheck against the real script.

Changes

  • New devcontainer-sh script, written for bash 3.2 (the macOS system bash): no associative arrays, no mapfile.
  • Removed functions/ and subcommands/.
  • "Subcommands" is now "commands" in the help, the unknown command error, the completions, the tests and the README.
  • action.yml: a composite action that puts devcontainer-sh on PATH and installs the devcontainer CLI when it is missing. It doesn't start anything.
  • Flake: packages.default (the script plus the zsh completions) and a dev shell with bats, shellcheck, zsh and actionlint.
  • CI: shellcheck, actionlint, nix build, tests on Linux and macOS (macOS also runs the suite under the system bash 3.2), an integration job that uses the action against a real container, and the major version tag (v1) moved on release.
  • release-please keeps the DEVCONTAINER_SH_VERSION line in the script current.
  • Behavior is otherwise the same, with three small fixes:
    • exec no longer mistakes a --workspace-folder after -- (the command's own flag) for its own.
    • build -p with no value fails with a clear error.
    • down fails when docker ps itself fails, instead of reporting "no container found".

Tests

38 bats tests pass on bash 5.3 and on macOS's bash 3.2.57, and shellcheck and actionlint are clean. The tests run the real script with stubbed devcontainer and docker. The two that sourced zsh internals check the same behavior through exec and down, and plugin.bats covers the zsh plugin. I also ran up, exec, a failing exec and down by hand against a real container, calling the script by path. (My first attempt was not valid: in my shell devcontainer-sh resolved to the old zsh function, so it exercised the old code. The numbers here are from the second run.)

Known limitation

down finds containers by the devcontainer.local_folder label, which the CLI sets only on the workspace container. For a compose-based devcontainer the other services carry only the com.docker.compose.project label, so down leaves them (and the compose network) behind. That was already true before this PR. It only matters on self-hosted runners, since hosted runners are discarded after the job. Not fixed here.

The tool is now bin/devcontainer-sh, a bash 3.2 compatible executable that
works from any shell and from CI. The zsh plugin only puts it on PATH and
registers completions. Subcommands are now called commands.
- action.yml puts devcontainer-sh on PATH and installs the devcontainer CLI
- flake package with the zsh completions
- CI: shellcheck, actionlint, nix build, tests on Linux and macOS (also with
  the system bash 3.2), an integration job that uses the action, and the major
  version tag moved on release
- release-please keeps the version in the script current
@iamralch iamralch self-assigned this Nov 19, 2026
@iamralch
iamralch marked this pull request as ready for review November 19, 2026 09:07
@iamralch
iamralch merged commit b48e5e4 into main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant