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
grep includes the i flag #876
Changes from 1 commit
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ common.register('grep', _grep, { | |
cmdOptions: { | ||
'v': 'inverse', | ||
'l': 'nameOnly', | ||
'i': 'ignoreCase', | ||
}, | ||
}); | ||
|
||
|
@@ -17,7 +18,8 @@ common.register('grep', _grep, { | |
//@ Available options: | ||
//@ | ||
//@ + `-v`: Invert `regex_filter` (only print non-matching lines). | ||
//@ + `-l`: Print only filenames of matching files | ||
//@ + `-l`: Print only filenames of matching files. | ||
//@ + `-i`: Ignored upper/lower case differences. | ||
//@ | ||
//@ Examples: | ||
//@ | ||
|
@@ -48,6 +50,9 @@ function _grep(options, regex, files) { | |
} | ||
|
||
var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); | ||
if (options.ignoreCase) { | ||
regex = new RegExp(regex, 'i'); | ||
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. Sorry, one more fix: move the 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. Oh, it's a low-level error, i fixed it, sorry. |
||
} | ||
if (options.nameOnly) { | ||
if (contents.match(regex)) { | ||
grep.push(file); | ||
|
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.
nit: can you change this sentence to simply "Ignore case."?