Skip to content

Add portable temporary file and directory helpers to lib_std.sh #53

@codeforester

Description

@codeforester

Context

Portable mktemp usage is easy to get wrong across macOS and Linux, especially around mktemp -t. lib_std.sh should provide simple temp file and directory helpers that follow Base conventions and integrate with cleanup registration.

Scope

Add Base-native temp helpers to lib_std.sh, built on the cleanup/trap registration API. Do not copy external implementations.

Acceptance Criteria

  • Public helpers create a temp file and a temp directory using caller-provided result variables.
  • Helpers avoid platform-specific mktemp -t assumptions and work with ${TMPDIR:-/tmp}.
  • Temp paths are registered for cleanup by default.
  • A clear opt-out exists for callers that intentionally need to keep the temp path.
  • Invalid result variable names fail clearly.
  • Public API and behavior are documented in lib/bash/std/README.md.
  • BATS coverage verifies file creation, directory creation, prefixes, cleanup registration, opt-out behavior, 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