Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

grep includes the i flag #876

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

Merged
merged 5 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add the i flag to grep
  • Loading branch information
ppsleep committed Jul 20, 2018
commit 734e287802186f61ba7082f0aa5756df51a04709
3 changes: 2 additions & 1 deletion 3 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ include the base directories (e.g., `lib/resources/file1` instead of just `file1
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`: Ignore case.

Examples:

Expand Down
2 changes: 1 addition & 1 deletion 2 src/grep.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ common.register('grep', _grep, {
//@
//@ + `-v`: Invert `regex_filter` (only print non-matching lines).
//@ + `-l`: Print only filenames of matching files.
//@ + `-i`: Ignored upper/lower case differences.
//@ + `-i`: Ignore case.
//@
//@ Examples:
//@
Expand Down
7 changes: 7 additions & 0 deletions 7 test/grep.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ test('-l option', t => {
t.is(result.split('\n').length - 1, 2);
});

test('-i option', t => {
const result = shell.grep('-i', 'test', 'test/resources/case1', 'test/resources/case1.txt',
'test/resources/case1.js');
t.falsy(shell.error());
t.is(result.split('\n').length - 1, 3);
});

test('the pattern looks like an option', t => {
const result = shell.grep('--', '-v', 'test/resources/grep/file2');
t.falsy(shell.error());
Expand Down
1 change: 1 addition & 0 deletions 1 test/resources/case1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test3
Copy link
Member

Choose a reason for hiding this comment

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

This is OK, but could you move these files under test/resources/grep/case1*? That should fix the other failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I moved it, and sorry for my thoughtless actions.

1 change: 1 addition & 0 deletions 1 test/resources/case1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test3
1 change: 1 addition & 0 deletions 1 test/resources/case1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TEST3
Morty Proxy This is a proxified and sanitized view of the page, visit original site.