diff options
author | Eitan Adler <eadler@FreeBSD.org> | 2012-12-20 17:38:14 +0000 |
---|---|---|
committer | Eitan Adler <eadler@FreeBSD.org> | 2012-12-20 17:38:14 +0000 |
commit | 924500b74dfb40cdfde0707fc58e294abc91fadc (patch) | |
tree | 7e80a178845ab1ecc1c7f96d387b987540d59abf /usr.bin/grep/grep.c | |
parent | f578aba724c88d2a4d42d0d9a6e2d239c058ca6d (diff) | |
download | src-924500b74dfb40cdfde0707fc58e294abc91fadc.tar.gz src-924500b74dfb40cdfde0707fc58e294abc91fadc.zip |
Make bsdgrep behave as gnugrep and as documented: -m should only stop
reading the specific file, not any file.
Tested by: frogs (irc)
Reviewed by: gabor
Approved by: cperciva (implicit)
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=244493
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 43d93347230c..7c69d5d29a3b 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -108,6 +108,7 @@ bool iflag; /* -i: ignore case */ bool lflag; /* -l: only show names of files with matches */ bool mflag; /* -m x: stop reading the files after x matches */ long long mcount; /* count for -m */ +long long mlimit; /* requested value for -m */ bool nflag; /* -n: show line numbers in front of matching lines */ bool oflag; /* -o: print only matching part */ bool qflag; /* -q: quiet mode (don't output anything) */ @@ -524,7 +525,7 @@ main(int argc, char *argv[]) case 'm': mflag = true; errno = 0; - mcount = strtoll(optarg, &ep, 10); + mlimit = mcount = strtoll(optarg, &ep, 10); if (((errno == ERANGE) && (mcount == LLONG_MAX)) || ((errno == EINVAL) && (mcount == 0))) err(2, NULL); |