I have noticed an annoying change in grep -r --exclude-dir behaviour. Consider the following test:mkdir -p ./d1/d2echo 'randomtext' > ./d1/d2/testfilegrep -nr --exclude-dir ./d1/d2 'randomtext'An expected behaviour is that grep would not show testfile as it should be filtered via --exclude-dir. That works for grep v2.10 and 2.11. However for versions 2.12+ the output is:./d1/d2/testfile:1:randomtextMoreover, the behaviour is inconsistent: grep -nr --exclude-dir d1 'randomtext'# or grep -nr --exclude-dir d2 'randomtext'Work fine, without any output, as expected. I believe that it is a bug. Can you please confirm my theory? Thank you.
grep --exclude-dir behaviour: a bug or a feature?
grep
Between v2.11 and v2.12, the grep changelog mentions only the following change about --exclude-dir:grep: fix segfault with -r --exclude-dir and no file operandI suppose that the change of behavior is a side effect of this fix (which is exactly your case), i.e. a bug has been introduced, but as you can see, grep could also segfault in this case before v2.12. So, do not expect v2.11 to be reliable.I suggest that you report this bug.Note: This segfault was due to a fix in v2.11. The NEWS file says for v2.11:The --include, --exclude, and --exclude-dir options now handlecommand-line arguments more consistently.  --include and --excludeapply only to non-directories and --exclude-dir applies only todirectories.  - (standard input) is never excluded, since it isnot a file name.[bug introduced in grep-2.5]and for v2.12:grep no longer segfaults with -r --exclude-dir and no file operand.I.e., :|grep -r --exclude-dir=D PAT would segfault.[bug introduced in grep-2.11]