Context
Follow-up from basefoundry/base#1380. That PR made basectl update-profile --remove reversible and safe, and it already uses update_file_section -r from base-bash-libs for the actual marker-delimited removal.
The remaining reusable logic lives in Base: before removing a managed section, update-profile needs to know whether a target file contains the full-line marker pair so it can report dry-run output and create backups only when removal would actually change the file.
Proposed shape
Add a public lib/bash/file/lib_file.sh helper for marker-delimited section inspection, for example file_section_exists or file_section_needs_change, that callers can use before update_file_section -r.
The helper should reuse the same semantics as update_file_section:
- Treat markers as exact full lines.
- Reject asymmetric or misordered marker pairs with the same manual-repair posture.
- Return a clean no-change result when the target file is missing or the section is absent.
- Avoid modifying the target file.
- Be suitable for dry-run and backup decisions in Base callers.
Acceptance criteria
lib/bash/file/lib_file.sh exposes a documented public helper for section inspection.
- BATS coverage includes present, absent, missing-file, asymmetric-marker, and misordered-marker cases.
lib/bash/file/README.md documents the helper and its return contract.
- A follow-up Base PR can replace
base_update_profile_remove_file_needs_change with the shared helper after this lands.
Related: basefoundry/base#1366, basefoundry/base#1380
Context
Follow-up from basefoundry/base#1380. That PR made
basectl update-profile --removereversible and safe, and it already usesupdate_file_section -rfrombase-bash-libsfor the actual marker-delimited removal.The remaining reusable logic lives in Base: before removing a managed section,
update-profileneeds to know whether a target file contains the full-line marker pair so it can report dry-run output and create backups only when removal would actually change the file.Proposed shape
Add a public
lib/bash/file/lib_file.shhelper for marker-delimited section inspection, for examplefile_section_existsorfile_section_needs_change, that callers can use beforeupdate_file_section -r.The helper should reuse the same semantics as
update_file_section:Acceptance criteria
lib/bash/file/lib_file.shexposes a documented public helper for section inspection.lib/bash/file/README.mddocuments the helper and its return contract.base_update_profile_remove_file_needs_changewith the shared helper after this lands.Related: basefoundry/base#1366, basefoundry/base#1380