Fix _purge_line when noclobber is enabled#88
Conversation
…redirect with portable grep-based line removal
|
Thanks for raising this issue again and for submission. I ended up using using the solution proposed here: https://github.com/huyng/bashmarks/pull/66/changes |
|
Thanks for reviewing the patch. The portable fix I proposed here avoids redirects entirely and works across GNU/BSD sed, BusyBox, and all shells (bash, zsh, dash, ash), regardless of when Because of that, the Hopefully you will consider re‑opening this PR, as the portable fix handles |
Summary
This PR fixes a failure in
_purge_linewhen Bash is configured withset -o noclobber(orset -C).The previous implementation could fail while updating the bookmarks file because of the way the temporary file was created and written. As a result, commands that remove or update bookmarks would not work correctly in shells with
noclobberenabled.Changes
_purge_line.sed-based temporary file workflow with agrep -vfilter.mktempfor secure temporary file creation before replacing the original file.Why
Many users enable
noclobberin their.bashrcor.bash_profileto prevent accidental file overwrites. This change makesbashmarksbehave correctly in that configuration without requiring users to disable the option.Testing
Tested by enabling:
set -o noclobberand verifying that bookmark removal/update operations complete successfully.