Skip to content

Align update_file_section removal with single-section update semantics #78

Description

@codeforester

Context

update_file_section has asymmetric behavior when multiple sections use the same marker pair. The update path replaces only the first matching section, while the remove path deletes every matching START...END pair.

Failure Scenario

A file contains two sequential sections with the same markers.

  • update_file_section file "# BEGIN" "# END" new updates only the first section.
  • update_file_section -r file "# BEGIN" "# END" removes both sections.

That asymmetry can delete content the caller did not intend to manage.

Scope

  • Decide and implement the canonical behavior for duplicate matching marker pairs.
  • Prefer aligning remove with update by removing only the first matching section, unless duplicate markers should instead be rejected as ambiguous.
  • Update function docs and README text to describe the chosen behavior.
  • Add BATS coverage for multiple matching sections.

Acceptance Criteria

  • Add/update/remove behavior agrees for duplicate marker pairs.
  • The chosen behavior is documented.
  • Existing single-section behavior remains unchanged.
  • ./tests/validate.sh passes.

Validation

  • ./tests/validate.sh

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions