fix: regexes are more consistent with sed and grep#303
Merged
ariporad merged 1 commit intoshelljs:masterfrom Jan 24, 2016
nfischer:more-regex-tests
Merged
fix: regexes are more consistent with sed and grep#303ariporad merged 1 commit intoshelljs:masterfrom nfischer:more-regex-tests
ariporad merged 1 commit intoshelljs:masterfrom
nfischer:more-regex-tests
Conversation
src/sed.js
Outdated
Contributor
There was a problem hiding this comment.
[Slight Nitpick]: Maybe just simplify to:
var result = fs.readFileSync(file, 'utf8').split('\n').map(function (line) {
return line.replace(regex, replacement);
}).join('\n');
Member
Author
There was a problem hiding this comment.
I originally wrote it like that. I switched it because I thought we might later want to modify sed to return a list (similar what ls() does) instead of return a multi line string. I can revert this back though
Contributor
|
One small nitpick, but otherwise LGTM! |
sed will now convert search strings to regex form, so `'a*'` will now work like `/a*/`. Also, new tests for grep and sed ensure that '*' is not expanded for filename globbing.
Member
Author
|
@ariporad updated to address your comment. Feel free to merge once tests pass. |
ariporad
added a commit
that referenced
this pull request
Jan 24, 2016
fix: regexes are more consistent with sed and grep
Contributor
|
Merged |
Closed
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.
sed()will now convert search strings to regex form, so'a*'will now work like/a*/. Also, new tests for grep and sed ensure that*is not expanded for filename globbing.While the filename globbing isn't currently an issue, I anticipate that it could be a problem if we don't handle
sed()andgrep()carefully when doing filename globbing as part of thewrap()function (which I think is the way this project should go). These tests are an extra guard to make sure we don't make any mistakes.So this should probably be merged before #275 to be safe.