Skip to content

feat(preflight): add an opt-in Bash version probe #1585

Description

@coygeek

Summary

Add bash as an opt-in name accepted by --preflight-tools and run.preflightTools on POSIX and WSL2 targets. Report the resolved Bash version in Crabbox's normalized pre-command capability snapshot without installing Bash or changing the workload.

Problem to solve

Crabbox can report Go, Cargo, Make, CMake, Python, and JavaScript tool versions, but it cannot report the Bash version used by shell tests and build scripts. Exact current main rejects the conventional command name before provider work:

$ crabbox run --provider local-container --no-sync \
    --preflight --preflight-tools bash -- true
unknown preflight tool "bash"
$ echo $?
2

The provider inventory remains empty after the rejection.

This matters when a project depends on Bash behavior rather than generic POSIX shell syntax. During a clean mvdan/sh v3.14.0 verification, host-confirmation tests disagreed between macOS and Linux builds of Bash 5.3.9. The clean runner had to print bash --version from an uploaded script because the requested preflight probe was unavailable. A version result would not replace behavioral tests, but it would bind their outcome to the actual shell runtime instead of leaving that runtime implicit.

Crabbox's POSIX capability snapshot itself currently invokes bash -lc. A host without Bash therefore produces a generic preflight failure before any per-tool result can identify the missing prerequisite.

Proposed behavior

  • Accept bash as an opt-in built-in preflight name on Linux, macOS, and WSL2.
  • Probe the literal bash --version command and report its first bounded output line when present.
  • Report a stable Bash-unavailable result when the command is missing, without converting the diagnostic probe into a workload failure.
  • Keep bash out of the default probe list.
  • Preserve exit 2 before acquisition for names that are not in the registry.
  • Skip native Windows unless the project adopts a separate literal Bash command contract there.

The missing-command behavior must account for the current Bash-dependent POSIX preflight wrapper. A requested Bash probe should not collapse into an unclassified remote preflight failed message.

Acceptance criteria

  • --preflight-tools bash validates on Linux, macOS, and WSL2.
  • run.preflightTools: [bash] accepts the same probe from repository and user configuration.
  • A target with Bash reports the first bounded line from bash --version before the user command starts.
  • A target without Bash reports a stable unavailable state and still runs a user command that does not require Bash.
  • default,bash,bash emits the ordinary default probes plus one Bash result.
  • Native Windows skips the probe unless a separate supported command contract is defined.
  • Bash remains opt-in and Crabbox never installs, upgrades, or selects a shell.
  • Unknown names still exit 2 before a lease or provider resource is acquired.
  • Tests cover name validation, configuration, deduplication, target filtering, present and missing Bash, the Bash-dependent POSIX wrapper, and the unchanged unknown-name guard.
  • Run, observability, and configuration documentation lists the probe and its target support.

Affected area

  • Preflight registration, validation, target filtering, and POSIX command generation in internal/cli/run_observability.go.
  • Preflight behavior and configuration coverage in internal/cli/run_test.go.
  • docs/commands/run.md and docs/observability.md.

Non-goals

  • Adding Bash to the default preflight list.
  • Installing Bash or changing the target's default shell.
  • Treating a version string as proof that a script behaves correctly.
  • Probing Zsh, Dash, mksh, BusyBox, Fish, or PowerShell in this request.
  • Running a project script as part of the probe.
  • Defining a native-Windows Git Bash or MSYS2 discovery policy.

Alternatives considered

Print the version in every workload

An uploaded script can run bash --version, but each workflow must recreate the check and parse its output. The result is absent from Crabbox's normalized preflight snapshot and cannot be selected through run.preflightTools.

Probe sh

The sh command may resolve to Dash, Bash in a compatibility mode, BusyBox, or another implementation. It does not establish the Bash runtime used by a Bash test suite.

Add Bash to the default set

Many workloads do not depend on Bash identity. An opt-in probe keeps the default output stable and follows the existing language and build-tool pattern.

Supporting context

The complete seven-commit range from the release baseline through exact current main, the complete live open-issue and open-pull-request corpora, every open issue authored by coygeek, and relevant closed issues and merged pull requests were checked. No current item adds or requests a Bash version preflight probe.

Closed issue #1243 and merged pull request #1347 added the literal Python probes. Closed issue #1394 and merged pull request #1402 added the analogous CMake probe. Those changes establish the opt-in literal-command pattern while keeping unknown names fail-closed before acquisition, but neither covers Bash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:bulk-filedClawSweeper detected a high recent issue-filing volume from this author.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions