fix(sed): preserve escaped replacement characters - #252
Open
Voyagerroc-Lab wants to merge 1 commit into
Open
Voyagerroc-Lab wants to merge 1 commit into
Voyagerroc-Lab wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
shx sedsilently corrupts escaped replacement characters. For example, replacingfoowith the escaped Windows pathC:\\temp\\file.txtproducesC:.temp.file.txtand exits successfully. This also affects-i, writing the corrupted path to disk.Unescape replacement characters in one pass, retaining the escaped character instead of substituting a dot. A single pass also prevents adjacent escaped backslashes and slashes from being interpreted twice.
Regression tests exercise file input without
-g, stdin with adjacent escapes, and in-place global replacement. They verify output/file contents, exit status, and stderr. All three fail on unchanged main (3d4e06c49a4f4835b9f9aedc728a71d6b7b06493) and pass with the fix.Validation on Windows, Node v24.19.0:
src/cli.jsas a child process with piped input before and after the fix; confirmed both the Windows path and adjacent-backslash/slash reproductions.npm test: 42 passing, 3 existing platform skips for chmod; posttest ESLint passed.npm run check-node-support: passed.git diff --check: passed.This fixes literal replacement escaping only. It does not implement Unix sed basic regex syntax or numeric backreferences, and does not close the broader compatibility request #225. Other operating systems and Node versions were not run locally.