Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ed: buffer is dirty unless all lines were written #932

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Jan 27, 2025

  • I found a case where ed allowed unsaved changes to be lost
  • The default behaviour of "w" command is to write all lines from the editor buffer
  • In the case of 1w or 1,2w command, only the selected lines are written and there may be unsaved changes on other lines, so don't unset the "dirty" flag
  • The flag should be unmodified also in the case of "w !cat", where all buffer lines are written to a pipe
  • This patch makes ed consistent with BSD and GNU versions
%perl ed -p 'edmond>' a.s # desired behaviour
839
edmond>10d 
edmond>1w tmp.txt
13
edmond>q
?
edmond>h
buffer modified
edmond>Q

* I found a case where ed allowed unsaved changes to be lost
* The default behaviour of "w" command is to write all lines from the editor buffer
* In the case of 1w or 1,2w command, only the selected lines are written and there may be unsaved changes on other lines, so don't unset the "dirty" flag
* The flag should be unmodified also in the case of "w !cat", where all buffer lines are written to a pipe
* This patch makes ed consistent with BSD and GNU versions
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: ed The ed program labels Jan 27, 2025
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:05 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 27, 2025 02:06 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Jan 27, 2025

Pull Request Test Coverage Report for Build 12980707565

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 73.389%

Totals Coverage Status
Change from base Build 12946809738: 0.0%
Covered Lines: 353
Relevant Lines: 481

💛 - Coveralls

@briandfoy
Copy link
Owner

changes: buffer is dirty unless all lines were written

@briandfoy briandfoy self-assigned this Jan 27, 2025
@briandfoy briandfoy added Type: bug an existing feature does not work and removed Type: enhancement improve a feature that already exists labels Jan 27, 2025
@briandfoy briandfoy merged commit b5df2a2 into briandfoy:master Jan 27, 2025
22 of 23 checks passed
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: ed The ed program Status: accepted The fix is accepted Type: bug an existing feature does not work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants