Skip to content

Add timeout-aware command execution helper to lib_std.sh #51

@codeforester

Description

@codeforester

Context

Scripts sometimes call external tools that can hang. GNU systems often provide timeout; macOS may provide gtimeout through Homebrew coreutils, or no timeout binary at all. lib_std.sh should offer a small wrapper with clear behavior and Base-style command execution semantics.

Scope

Add a Base-native timeout-aware command helper to lib_std.sh. Do not copy external implementations.

Acceptance Criteria

  • Public helper runs a command with a timeout while preserving argument boundaries.
  • Prefer timeout, then gtimeout, when present.
  • Define and test clear behavior when neither timeout binary is available.
  • Preserve command exit status on normal command failure.
  • Support caller-handled failures in a style consistent with std_run --no-exit.
  • Do not use eval.
  • Public API and behavior are documented in lib/bash/std/README.md.
  • BATS coverage verifies success, command failure, timeout, missing command, missing timeout binary fallback, and invalid arguments.

Validation

  • Focused stdlib BATS coverage.
  • ./tests/validate.sh
  • `git diff --check

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or product improvement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions