Repository navigation
sed: keep an escaped ^ or $ literal in a plain-string pattern #638
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -766,6 +766,21 @@ fn test_word_boundaries_without_other_regex_characters() { | |
| .stdout_is("bar\n<bar\n"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_escaped_anchors_in_literal_pattern() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please run the GNU testsuite to check that nothing regresses?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ran it with ./util/run-gnu-testsuite.sh on main and on this branch and got identical results for every test, so nothing regresses. The GNU testsuite job on the PR also says no new failures vs main. |
||
| // \^ and \$ match a literal ^ and $, not the start or end of the line. | ||
| new_ucmd!() | ||
| .args(&["-e", r"s/\^/X/", "-e", r"s/\$/Y/"]) | ||
| .pipe_in("a^b$c\n") | ||
| .succeeds() | ||
| .stdout_is("aXbYc\n"); | ||
| new_ucmd!() | ||
| .args(&["-E", "-e", r"s/^a\$/X/", "-e", r"s/b\\$/Y/"]) | ||
| .pipe_in("a$b\\\na\n") | ||
| .succeeds() | ||
| .stdout_is("XY\na\n"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_unknown_escape_is_the_bare_character() { | ||
| new_ucmd!() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a few
LiteralMatcher::newunit tests too (\^a,a\$,^\^,a\\$) :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one for each of those,
\^a,a\$,^\^anda\\$, checking both what matches and where.