Skip to content

Commit a551843

Browse files
committed
grep: read -f file with strbuf_getline()
List of patterns file could come from a DOS editor. This is iffy; you may actually be trying to find a line with ^M in it on a system whose line ending is LF. You can of course work it around by having a line that has "^M^M^J", let the strbuf_getline() eat the last "^M^J", leaving just the single "^M" as the pattern. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 933bea9 commit a551843

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
562562
patterns = from_stdin ? stdin : fopen(arg, "r");
563563
if (!patterns)
564564
die_errno(_("cannot open '%s'"), arg);
565-
while (strbuf_getline_lf(&sb, patterns) == 0) {
565+
while (strbuf_getline(&sb, patterns) == 0) {
566566
/* ignore empty line like grep does */
567567
if (sb.len == 0)
568568
continue;

0 commit comments

Comments
 (0)