Skip to content

Fix exact-line marker detection in update_file_section #76

Description

@codeforester

Context

Claude flagged a mismatch between marker counting and section processing in lib/bash/file/lib_file.sh. I verified it locally.

update_file_section counts markers with grep -cF, which matches substrings anywhere on a line. The AWK update/remove logic uses exact full-line equality with $0 == START_M and $0 == END_M.

Failure Scenario

A file containing echo # BEGIN and echo # END with markers # BEGIN and # END is treated as having a managed section. The AWK logic never sees exact marker lines, so the function logs an update and returns success without changing the file.

Scope

  • Make marker counting use exact full-line semantics, consistent with the AWK processors.
  • Keep option-like markers working.
  • Add BATS coverage for embedded marker substrings that should not count as managed section markers.

Acceptance Criteria

  • Embedded marker substrings do not make section_exists=true.
  • Existing exact marker 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