Skip to content

Fail cleanly when sourced by unsupported Bash versions #6

Description

@codeforester

Context

The Bash libraries document Bash 4.2+ support, but lib_std.sh currently exposes only a passive check_bash_version helper and continues defining Bash-4-only functions during source-time initialization.

On macOS /bin/bash 3.2, sourcing the stdlib can emit raw syntax errors and still continue far enough to mislead callers.

Scope

  • Add a source-time guard near the top of lib/bash/std/lib_std.sh before Bash-4-specific syntax is parsed or executed as much as Bash allows.
  • Emit a concise, user-facing error that says Bash 4.2+ is required and includes the current $BASH_VERSION.
  • Return nonzero when sourced from an unsupported shell.
  • Keep check_bash_version available for supported shells as the passive helper.

Acceptance Criteria

  • Sourcing lib_std.sh under Bash 3.2 fails cleanly instead of producing parser/internal errors.
  • Sourcing under supported Bash versions still initializes normally.
  • Tests cover supported initialization and unsupported-version behavior.

Validation

  • ./tests/validate.sh

Suggested Branch

bug/<issue>-20260618-bash-version-guard

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions