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

fix: sed works with slashes in regex #77

Merged
merged 1 commit into from
Aug 18, 2016
Merged

fix: sed works with slashes in regex #77

merged 1 commit into from
Aug 18, 2016

Conversation

nfischer
Copy link
Member

This should make shx sed work a little bit better. Also, this should make the code a bit more readable. If you have any readability suggestions, chime in and I'll implement those.

@@ -37,10 +37,13 @@ export const shx = (argv) => {
newArgs = [];
let lookingForSubstString = true;
args.forEach((arg) => {
const match = arg.match(/^s\/(.*)\/(.*)\/(g?)$/);
const match = arg.match(/^s\/(.*[^\\])\/(.*[^\\])\/(g?)$/);
Copy link
Contributor

@ariporad ariporad Aug 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be /^s\/([^\\.]*)\/([^\\.]*)\/(g?)$/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ariporad A sed-regex is allowed to have backslashes in it, but it's not allowed to end in a backslash. The end of a sed-regex is designated by the first appearance of a non-escaped /. If you want to include a / in the regex, you would use \/. I think your JS-regex would prevent that from working.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@codecov-io
Copy link

codecov-io commented Aug 15, 2016

Current coverage is 85.00% (diff: 100%)

Merging #77 into master will increase coverage by 1.66%

@@             master        #77   diff @@
==========================================
  Files             2          2          
  Lines            18         20     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits             15         17     +2   
  Misses            3          3          
  Partials          0          0          

Powered by Codecov. Last update 1fe09e3...31c845c

@ariporad
Copy link
Contributor

LGTM!

@nfischer
Copy link
Member Author

LGTM

@nfischer nfischer merged commit e25e567 into master Aug 18, 2016
@nfischer nfischer deleted the fix-sed-regex branch August 18, 2016 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants