| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
| |
Fixes: da5d94d29a5e ("Remove obsolete BUGS section from zgrep(1) man page, add test")
|
| |
|
|
|
|
|
|
|
|
| |
I forgot to check/update the man page with D54217. While here add
a test for multiple -e flags.
Reviewed by: markj
Approved by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54632
|
| |
|
|
|
| |
Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/1442
|
| |
|
|
|
|
|
|
|
|
|
|
| |
@bdrewery reported D48873 broke "bzgrep -q '1 2' /var/log/messages.0.bz2"
The mistake was in using $* instead of "$@" (I suspect $* is never right).
Reported by: bdrewery
Reviewed by: markj
Approved by: markj
Fixes: 1070477cc8b7 ("Fix remaining zgrep(1) wrapper script regressions")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54217
|
| |
|
|
|
|
|
|
| |
grep|tee of the src/ tree for infrequently-occurring strings is fairly
annoying; drop some tactical flushes at line-match boundaries to reduce
the long stalls. In the case of `grep -o`, we'll flush after multiple
lines if there are multiple matches within a single line of text, while
for non`-o` we'll flush generally after every line.
|
| |
|
|
|
| |
Reviewed by: ivy
Differential Revision: https://reviews.freebsd.org/D51530
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For the default uncolored output, we'll just output a line once and then
move on. For colored output, we'll output multiple matches per
line with context from the line interspersed and may end up writing out
some match context multiple times as we don't persist which part of the
lines have already been printed.
Fix it by tracking the length of line printed thus far in printline()
and retaining it across successive calls to printline() in the same
line. printline() should indicate whether it terminated the line or not
to avoid tracking the logic for that in multiple places: -o lines are
always terminated, so it's generally only some --color contexts where we
wouldn't have terminated.
Add a test to make sure that we're only printing one line going forward.
Reported and tested by: Jamie Landeg-Jones <jamie catflap org>
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D49324
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Fix short flags without whitespace, e.g:
zgrep -wefoo test
Fix multiple -e flags:
zgrep -e foo -e xxx test
Previously only the last pattern would be used.
Clean up possible leading blank in ${grep_args}.
Update comment: 2.51 -> 2.6.0
Add a test case for the last known zgrep wrapper issue: recursion
(-r) not implemented.
Reviewers: markj, kevans, ngie, bapt
Reviewed By: markj
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D48873
|
| |
|
|
|
|
|
|
|
|
|
| |
This matches the documented behavior in the manpage as well as the
default behavior on macOS.
PR: 280676
Reported by: Radosław Piliszek <radoslaw.piliszek@gmail.com>
Reviewed by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D46256
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The -OpS options were effectively ignored due to a collection of
bugs in the use of fts(3):
- fts_open(3) requires one of FTS_PHYSICAL or FTS_LOGICAL to be
specified, but in the -O case, only FTS_COMFOLLOW was given. Fix
this to use FTS_COMFOLLOW | FTS_PHYSICAL.
- The switch on the entry type returned by fts_read() did not check
for symbolic links, so symbolic links fell into the default case and
were always passed to procfile() even when -p was given. Fix this
by adding cases in the switch statement to explicitly ignore FTS_SL.
- FTS_NOSTAT was passed to fts_open(), so fts_open() couldn't detect
symbolic links when FTS_PHYSICAL was passed, instead both regular
files and symbolic links were returned as FTS_NSOK entries. Fix
by only using FTS_NOSTAT with FTS_LOGICAL.
While here, fix a few other nits:
- Treat FTS_NS as an error like FTS_DNR and FTS_ERR.
- Just ignore FTS_DP. The logic to skip descending into skipped
directories is only relevant when a directory is first visited, not
after the directory has been visited.
- Use warnc instead of warnx + strerror.
PR: 280676
Reviewed by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D46255
|
| |
|
|
|
|
|
| |
This is a residual of the $FreeBSD$ removal.
MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
The very few places that rely on malloc/calloc of a zero-size region
won't attempt to dereference it, so just return NULL rather than rolling
the dice with the underlying malloc implementation.
Reported by: brooks, Shawn Webb
|
| |
|
|
|
|
|
| |
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kevans
|
| | |
|
| |
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
|
| |
|
|
| |
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
|
| |
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
|
| |
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| |
|
|
| |
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
|
| |
|
|
|
|
|
|
|
| |
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix
|
| | |
|
| |
|
|
|
|
| |
st_size is an off_t, it cannot hold values larger than OFF_MAX.
CID: 1008931
|
| |
|
|
|
|
| |
This reverts commit f6d6c66889001208aee7b0c46efe1c8ddffda57c.
Gremlins snuck into my tree and injected some WIP.
|
| |
|
|
|
|
| |
st_size is an off_t, it cannot hold values larger than OFF_MAX.
CID: 1008931
|
| |
|
|
|
|
|
|
|
|
|
|
| |
-z is supposed to use only the NUL byte as EOL, but we were
inadvertently using both newline and NUL due to REG_NEWLINE in cflags.
The odds of anyone relying on this bsdgrep-specific bug are quite low,
so let's just fix it. At least one port in the wild has been reported
to expect the intended behavior.
Reported by: Hill Ma <maahiuzeon@gmail.com>
Triaged by: the self-proclaimed peanut gallery on Discord
|
| |
|
|
|
|
|
|
| |
Document the environment variables used by grep(1).
Reviewed by: pauamma, kevans
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D37726
|
| |
|
|
|
|
| |
MFC after: 1 week
Fixes: 4dc88ebedf94 ("Add BSD grep to the base system...")
Pull Request: https://github.com/freebsd/freebsd-src/pull/622
|
| |
|
|
|
|
|
| |
Examples uses --include=*.h which doesn't work as intended
Approved by: kevans
Differential Revision: https://reviews.freebsd.org/D36883
|
| |
|
|
|
|
|
|
|
| |
Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime.
This is everything needed to boot to multiuser with FreeBSD-rc installed.
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33435
|
| |
|
|
|
|
|
|
|
|
|
|
| |
-P in gnugrepland means PCRE, which we do not support. We may eventually
support it if onigmo ends up getting imported as a more performant regex
implementation, and we can re-add it properly in these places (and more)
when that time comes.
The optstr change is a functional nop; the case was not explicitly handled,
thus ending in usage() anyways.
Reported by: Vladimir Misev (via twitter)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the quite (-q) flag is provided, we don't expect any output.
Currently, the behavior is broken:
$ grep -cq flag util.c
1
$ grep -cs flag util.c
55
First of all, we print a number to stdout. Secondly, it just returns
0 or 1 (which is unexpected). GNU grep with c and q flags doesn't
print anything.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31108
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
"zgrep --version" is expected to print the version information in the
same way as "zgrep -V". However, the case handling the --version flag
is never reached, so "zgrep --version" prints:
zgrep: missing pattern
instead of:
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
Reviewed by: yuripv
Approved by: yuripv (src)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29813
|
| |
|
|
|
|
|
|
|
|
|
| |
It seems that the number of lines is no longer an optional parameter to
the -C flag. Document it accordingly both in the manual page and the
usage message.
Reviewed by: yuripv
Approved by: yuripv
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28509
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I found this when compiling all the bootstrap tools with -fsanitize=addres:
==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8
READ of size 32769 at 0x62d000008400 thread T0
#0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052)
#1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8
#2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18
#3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8
0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400)
allocated by thread T0 here:
#0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d)
#1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13
#2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c
#3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8
SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec
Reviewed By: kevans
MFC after: 1 week
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The basic issue here is that grep, when given -m 1, would stop all
line processing once it hit the match count and exit immediately. The
problem with exiting immediately is that -A processing only happens when
subsequent lines are processed and do not match.
The fix here is relatively easy; when bsdgrep matches a line, it resets
the 'tail' of the matching context to the value supplied to -A and
dumps anything that's been queued up for -B. After the current line has
been printed and tail is reset, we check our mcount and do what's
needed. Therefore, at the time that we decide we're doing nothing, we
know that 'tail' of the context is correct and we can simply continue
on if there's still more to pick up.
With this change, we still bail out immediately if there's been no -A
flag. If -A was supplied, we signal that we should continue on. However,
subsequent lines will not even bothere to try and process the line. We
have reached the match count, so even if the next line would match then
we must process it if it hadn't. Thus, the loop in procfile() can
short-circuit and just process the line as a non-match until
procmatches() indicates that it's safe to stop.
A test has been added to reflect both that we should be picking up the
next line and that the next line should be considered a non-match even
if it should have been.
PR: 253350
MFC-after: 3 days
|
| |
|
|
|
| |
-x overcomes -w in gnugrep, and it should here as well. Flip it off as
needed to avoid confusing other parts of grep.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The null pattern semantics were terrible because I tried to match gnugrep,
but I got it wrong. Let's unwind that:
- The null pattern should match every line if neither -w nor -x.
- The null pattern should match empty lines if -x.
- The null pattern should not match any lines if -w.
The first two will stop processing (shortcut) even if additional patterns
are specified. In any other case, we will continue processing other
patterns. If no other patterns are specified beside a null pattern, then
we match if neither -w nor -x or set and do not match if either of those
are specified.
The justification for -w is that it should match on a whole word, but the
null pattern deos not have a whole word to match on.
Empty pattern files should never match anything, and more importantly, -v
should cause everything to be written.
PR: 253209
MFC-after: 4 days
|
| |
|
|
|
|
| |
zstdegrep was listed twice, instead of zstdfgrep
Pull Request: https://github.com/freebsd/freebsd-src/pull/450
|
| |
|
|
| |
Differential Revision: https://reviews.freebsd.org/D27732
|
| |
|
|
|
|
|
|
|
| |
Unconditionally install bsdgrep as grep, bootstrap or not. Remove all
build glue and stop installing both gnugrep and libgnuregex now that
all consumers of the latter are gone.
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27732
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
We know up front how many items we can have in the queue (-B/Bflag), so
pay the cost of those particular allocations early on.
The reduced queue maintenance overhead seemed to yield about an ~8%
improvement for my earlier `grep -C8 -r closefrom .` test.
MFC after: 2 weeks
Notes:
svn path=/head/; revision=368483
|
| |
|
|
|
|
|
|
| |
libregex now supports these and we no longer offer to not link against
libregex.
Notes:
svn path=/head/; revision=368482
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.
As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it. Otherwise we might see
a random error from one of the iterations.
gzip is ignoring most errors and could be improved separately.
Reviewed by: vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27184
Notes:
svn path=/head/; revision=368467
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
r368355 removed the GNU_GREP_COMPAT knob (off by default) and forgot that
bsdgrep may be built/used for bootstrap on some systems.
All base uses should strive to use only POSIX-compliant expressions anyways
and we haven't had libregex by default here up to this point, so just don't
do that if we're bootstrapping.
Note that the resulting binary has the wrong `grep -V` information as it
falsely claims to be GNU compatible, but it is only for bootstrap.
Reported by: GitHub cross-builds via yuripv
Notes:
svn path=/head/; revision=368392
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This was introduced and then disabled by default primarily to avoid dealing
with bugs in libgnuregex. rS363823 switched to using libregex for it, so
let's just rip the option out now so we can make sure we're getting tested
with libregex via bsdgrep.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D27476
Notes:
svn path=/head/; revision=368355
|
| |
|
|
|
|
|
|
| |
PR: 248813
MFC after: 1 week
Notes:
svn path=/head/; revision=367866
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add more EXAMPLES covering flags: -A, -B, -c, -f, -i, -H, -l, -q, -R, -w
* While here, change existing wording to use the imperative (remove "To
find")
* Reword first example to be consistent with how grep(1) understand
words (-w)
Approved by: manpages (bcr@)
Differential Revision: https://reviews.freebsd.org/D27264
Notes:
svn path=/head/; revision=367850
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
zgrep should exit with success when given multiple files and the
pattern is found in at least one file. Prior to this change,
it would exit with success only if the pattern was found in _every_ file.
Reviewed by: dab ngie
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D26616
Notes:
svn path=/head/; revision=366345
|