Skip to content

history: advance rskip by written lines, not entries - #723

Closed
dfherr wants to merge 1 commit into
akinomyoga:masterfrom
dfherr:fix-history-write-rskip-lines
Closed

dfherr wants to merge 1 commit into
akinomyoga:masterfrom
dfherr:fix-history-write-rskip-lines

Conversation

@dfherr

@dfherr dfherr commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

While fixing the other two issues I found in-memory duplication across tabs.

.write advanced rskip (the number of HISTFILE lines already consumed) by the number of entries it wrote. With HISTTIMEFORMAT every entry takes two lines, and the entries collected by .initialize from history -a were not counted at all, so rskip fell short after each own write. history -a's fetch then picked up this session's own last command as new, and the next time another tab wrote to HISTFILE those commands were loaded again as duplicates.

The awk now counts the lines it writes and rskip is advanced by that number. The program is stored in awk_script so the count can be captured with ble/util/assign, the same pattern .read uses.

Comment thread src/history.sh
END { flush_line(); print nline; }
'
ble/builtin/history/.add-rskip "$file" "$_ble_builtin_history_histapp_count"
# Note: rskip counts lines, and an entry takes two lines with HISTTIMEFORMAT.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't defined whether rskip represents the number of lines or the number of entries. The issue is that some places assume one, and other places assume the other. This PR seems to define it as the number of lines, but I need to think about which should be chosen. Making rskip the number of lines may make it difficult to correctly handle the issue in #721. Also, it seems inconsistent with wskip, which is a source of confusion.

@dfherr

dfherr commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

closing as i will combine it with #721 as it will matter for doing that one correctly

@dfherr dfherr closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants