Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/grep grep: when -r is used, but no path argume...
details: https://anonhg.NetBSD.org/src/rev/bda7ba5788a2
branches: trunk
changeset: 369949:bda7ba5788a2
user: wiz <wiz%NetBSD.org@localhost>
date: Fri Sep 09 22:14:28 2022 +0000
description:
grep: when -r is used, but no path argument provided, search the current dir
As discussed on tech-userlevel.
diffstat:
distrib/sets/lists/tests/mi | 3 ++-
external/gpl2/grep/dist/doc/grep.1 | 9 +++++++--
external/gpl2/grep/dist/src/grep.c | 8 +++-----
tests/usr.bin/grep/Makefile | 3 ++-
tests/usr.bin/grep/d_recurse_noarg.out | 2 ++
tests/usr.bin/grep/t_grep.sh | 21 ++++++++++++++++++---
6 files changed, 34 insertions(+), 12 deletions(-)
diffs (139 lines):
diff -r 9729fc872d43 -r bda7ba5788a2 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Sep 09 19:37:15 2022 +0000
+++ b/distrib/sets/lists/tests/mi Fri Sep 09 22:14:28 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1222 2022/09/03 03:33:37 rillig Exp $
+# $NetBSD: mi,v 1.1223 2022/09/09 22:14:28 wiz Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4750,6 +4750,7 @@
./usr/tests/usr.bin/grep/d_invert.in tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/grep/d_invert.out tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/grep/d_recurse.out tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/grep/d_recurse_noarg.out tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/grep/d_recurse_symlink.err tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/grep/d_recurse_symlink.out tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/grep/d_whole_line.out tests-usr.bin-tests compattestfile,atf
diff -r 9729fc872d43 -r bda7ba5788a2 external/gpl2/grep/dist/doc/grep.1
--- a/external/gpl2/grep/dist/doc/grep.1 Fri Sep 09 19:37:15 2022 +0000
+++ b/external/gpl2/grep/dist/doc/grep.1 Fri Sep 09 22:14:28 2022 +0000
@@ -1,8 +1,8 @@
-.\" $NetBSD: grep.1,v 1.2 2016/01/10 22:16:40 christos Exp $
+.\" $NetBSD: grep.1,v 1.3 2022/09/09 22:14:29 wiz Exp $
.\"
.\" grep man page
.\"d Id: grep.1,v 1.23 2002/01/22 13:20:04 bero Exp
-.TH GREP 1 "June 16 2003" "GNU Project"
+.TH GREP 1 "September 3 2022" "GNU Project"
.SH NAME
grep, egrep, fgrep \- print lines matching a pattern
.SH SYNOPSIS
@@ -312,6 +312,11 @@
this is equivalent to the
.B "\-d recurse"
option.
+If no
+.IR FILE
+is given,
+.BR grep
+searches the current working directory.
.TP
.BR "\fR \fP \-\^\-include=" PATTERN
Recurse in directories only searching file matching
diff -r 9729fc872d43 -r bda7ba5788a2 external/gpl2/grep/dist/src/grep.c
--- a/external/gpl2/grep/dist/src/grep.c Fri Sep 09 19:37:15 2022 +0000
+++ b/external/gpl2/grep/dist/src/grep.c Fri Sep 09 22:14:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: grep.c,v 1.4 2021/12/28 19:22:58 christos Exp $ */
+/* $NetBSD: grep.c,v 1.5 2022/09/09 22:14:29 wiz Exp $ */
/* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -1764,10 +1764,8 @@
}
else
{
- if (directories == RECURSE_DIRECTORIES) {
- error (0, 0, _("warning: recursive search of stdin"));
- }
- status = grepfile ((char *) NULL, &stats_base);
+ status = grepfile(directories == RECURSE_DIRECTORIES ? "." : (char *) NULL,
+ &stats_base);
}
/* We register via atexit() to test stdout. */
diff -r 9729fc872d43 -r bda7ba5788a2 tests/usr.bin/grep/Makefile
--- a/tests/usr.bin/grep/Makefile Fri Sep 09 19:37:15 2022 +0000
+++ b/tests/usr.bin/grep/Makefile Fri Sep 09 22:14:28 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:13 jruoho Exp $
+# $NetBSD: Makefile,v 1.2 2022/09/09 22:14:29 wiz Exp $
NOMAN= # defined
@@ -30,6 +30,7 @@
FILES+= d_invert.in
FILES+= d_invert.out
FILES+= d_recurse.out
+FILES+= d_recurse_noarg.out
FILES+= d_recurse_symlink.err
FILES+= d_recurse_symlink.out
FILES+= d_whole_line.out
diff -r 9729fc872d43 -r bda7ba5788a2 tests/usr.bin/grep/d_recurse_noarg.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/grep/d_recurse_noarg.out Fri Sep 09 22:14:28 2022 +0000
@@ -0,0 +1,2 @@
+./a/f/favourite-fish:haddock
+./d/fish:haddock
diff -r 9729fc872d43 -r bda7ba5788a2 tests/usr.bin/grep/t_grep.sh
--- a/tests/usr.bin/grep/t_grep.sh Fri Sep 09 19:37:15 2022 +0000
+++ b/tests/usr.bin/grep/t_grep.sh Fri Sep 09 22:14:28 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_grep.sh,v 1.6 2021/08/30 23:14:14 rillig Exp $
+# $NetBSD: t_grep.sh,v 1.7 2022/09/09 22:14:29 wiz Exp $
#
# Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -31,7 +31,7 @@
atf_set "descr" "Checks basic functionality"
}
basic_body()
-{
+{
atf_check -o file:"$(atf_get_srcdir)/d_basic.out" -x \
'jot 10000 | grep 123'
}
@@ -62,6 +62,20 @@
atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" -x "grep -r haddock recurse | sort"
}
+atf_test_case recurse_noarg
+recurse_noarg_head()
+{
+ atf_set "descr" "Checks recursive searching without file argument"
+}
+recurse_noarg_body()
+{
+ mkdir -p recurse/a/f recurse/d
+ echo -e "cod\ndover sole\nhaddock\nhalibut\npilchard" > recurse/d/fish
+ echo -e "cod\nhaddock\nplaice" > recurse/a/f/favourite-fish
+
+ atf_check -o file:"$(atf_get_srcdir)/d_recurse_noarg.out" -x "cd recurse && grep -r haddock | sort"
+}
+
atf_test_case recurse_symlink
recurse_symlink_head()
{
@@ -329,9 +343,10 @@
atf_init_test_cases()
{
- atf_add_test_case basic
+ atf_add_test_case basic
atf_add_test_case binary
atf_add_test_case recurse
+ atf_add_test_case recurse_noarg
atf_add_test_case recurse_symlink
atf_add_test_case word_regexps
atf_add_test_case word_locale
Home |
Main Index |
Thread Index |
Old Index