Skip to content

Commit 4fe98b1

Browse files
committed
Make grep case insensitive
1 parent d67485e commit 4fe98b1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

notes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ grep_notes() {
2727
return 1
2828
fi
2929

30-
grep_output=$(grep -r "$notes_dir" -l -e "$*" 2>&1)
30+
grep_output=$(grep -r "$notes_dir" -li -e "$*" 2>&1)
3131
grep_result=$?
3232
formatted_output=$(printf "$grep_output" | without_notes_dir)
3333

test/test-grep.bats

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@ notes="./notes"
2222
}
2323

2424
@test "Should match only the files containing the given pattern when grepping" {
25-
echo "my-pattern" > $NOTES_DIRECTORY/matching-node.md
26-
echo "some-other-pattern" > $NOTES_DIRECTORY/non-matching-node.md
25+
echo "my-pattern" > $NOTES_DIRECTORY/matching-note.md
26+
echo "some-other-pattern" > $NOTES_DIRECTORY/non-matching-note.md
2727

2828
run $notes grep my-pattern
2929

3030
assert_success
31-
assert_line "matching-node.md"
32-
refute_line "non-matching-node.md"
31+
assert_line "matching-note.md"
32+
refute_line "non-matching-note.md"
33+
}
34+
35+
@test "Should grep case-insensitively" {
36+
echo "LETTERS" > $NOTES_DIRECTORY/matching-note.md
37+
38+
run $notes grep letter
39+
40+
assert_success
41+
assert_line "matching-note.md"
3342
}

0 commit comments

Comments
 (0)