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: avoid literal newline in s/// #917

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Jan 9, 2025

  • Yesterday when editing a file I discovered the escape sequence "\n" was expanded to a newline when used in a substitution command
  • This has the unintended result of updating one or more elements of the lines-list to contain multiple newline characters
  • GNU and OpenBSD versions treat "\n" as a regular "n"; follow this for compatibility, and to avoid the problem of line x containing many lines
%perl ed.old -p 'ed>' a.c
623
ed>1
#include <stdio.h>
ed>s/h/\nH\nI\n\nJ\n/
ed>p
#include <stdio.
H
I

J
>
ed>Q
%perl ed.new -p 'ed>' a.c
623
ed>1
#include <stdio.h>
ed>s/h/\nH\nI\n\nJ\n/
ed>p
#include <stdio.nHnInnJn>
ed>Q

* Yesterday when editing a file I discovered the escape sequence "\n" was expanded to a newline when used in a substitution command
* This has the unintended result of updating one or more elements of the lines-list to contain multiple newline characters
* GNU and OpenBSD versions treat "\n" as a regular "n"; follow this for compatibility, and to avoid the problem of line x containing many lines
@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 9, 2025
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:44 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 9, 2025 02:45 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Jan 9, 2025

Pull Request Test Coverage Report for Build 12682668341

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 73.389%

Totals Coverage Status
Change from base Build 12682335465: -0.7%
Covered Lines: 353
Relevant Lines: 481

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12682668342

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 73.389%

Totals Coverage Status
Change from base Build 12682335465: -0.7%
Covered Lines: 353
Relevant Lines: 481

💛 - Coveralls

@briandfoy briandfoy merged commit 147df70 into briandfoy:master Jan 9, 2025
21 of 23 checks passed
@briandfoy briandfoy self-assigned this Jan 9, 2025
@briandfoy briandfoy added Type: bug an existing feature does not work Status: accepted The fix is accepted and removed Type: enhancement improve a feature that already exists Priority: low get to this whenever labels Jan 9, 2025
@briandfoy
Copy link
Owner

changes: \n in a substitution is now just a literal n, not a newline

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