>From ef74f67e27ad76a26670eb5551202bd4b268294d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 3 Oct 2020 12:41:38 -0700 Subject: [PATCH] doc: document --include/--exclude better Problem reported by John Ruckstuhl (Bug#43782). * doc/grep.texi (File and Directory Selection): Document what happens if contradictory options are given, or if no option matches a file name. * doc/grep.in.1: --- doc/grep.in.1 | 11 +++++++++++ doc/grep.texi | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/doc/grep.in.1 b/doc/grep.in.1 index 91c0bca..7d5dfe5 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -680,6 +680,17 @@ Search only files whose base name matches .I GLOB (using wildcard matching as described under .BR \-\^\-exclude ). +If contradictory +.B \-\^\-include +and +.B \-\^\-exclude +options are given, the last matching one wins. +If no +.B \-\^\-include +or +.B \-\^\-exclude +options match, a file is included unless the first such option is +.BR \-\^\-include . .TP .BR \-r ", " \-\^\-recursive Read all files under each directory, recursively, diff --git a/doc/grep.texi b/doc/grep.texi index bb76ae1..0c0bb12 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -728,6 +728,10 @@ this is equivalent to the @samp{--binary-files=without-match} option. @cindex searching directory trees Search only files whose name matches @var{glob}, using wildcard matching as described under @option{--exclude}. +If contradictory @option{--include} and @option{--exclude} options are +given, the last matching one wins. If no @option{--include} or +@option{--exclude} options match, a file is included unless the first +such option is @option{--include}. @item -r @itemx --recursive -- 2.25.1